Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: logistic regression and factor variables


From   Rebecca Coates <r.coates@uq.edu.au>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: logistic regression and factor variables
Date   Mon, 11 Apr 2011 14:37:40 +1000

Hi,
I am having trouble with 'logit' and using factor variables. 
When I run this do file (the following is an excerpt, I am using factor variables so I can calculate the predictive margins post-estimation):

capture log close
log using ch6_analysis_c.log, replace text
// program:	ch6_analysis_predictivemargins.do
// task:	analysis for ch6, including predictive margins
// project: chapter 6
// author:	rebecca coates 11-APRIL-2011

// #0
// program set up

version 11.2
clear all
macro drop _all
set linesize 80
set more off

cd "H:\My File\12 DATA\04 Chapter 6"
use "H:\My File\12 DATA\04 Chapter 6\Data\chaptersix03.dta"




//#1

***************************************************************************************
//STAGE ONE ANALYSIS: WHAT ACCOUNTS FOR BEING ABLE TO ARTICULATE AN ASPIRATION OR PLAN?
***************************************************************************************

//Logistic regression models

//A) what accounts for being able to articulate an after-school plan?

//1=YES, they can articulate an after school plan; 0=NO, they cannot/the data is missing

logit plans2 female2 i.sector1 i.racode ib4.generation4 i.d51 ib4.edum2 ib4.eduf2 ib4.mother_asco5 ib5.father_asco5 [iweight=weight1]

I receive this error code from stata:

factor variables not allowed
r(101);

end of do-file

r(101);

HOWEVER, when I simply cut and past the following line of syntax out of my do-file into the stata command field and run it from there, like this: 

logit plans2 female2 i.sector1 i.racode ib4.generation4 i.d51 ib4.edum2 ib4.eduf2 ib4.mother_asco5 ib5.father_asco5 [iweight=weight1]

It runs fine and produces the expected output of a logistical regression table. 

I don't understand why this is happening. Any help would be much appreciated!
Many thanks for your time in anticipation,
Rebecca

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index