Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: logistic regression and factor variables


From   Rebecca Coates <[email protected]>
To   "[email protected]" <[email protected]>
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index