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]
RE: st: regression using generalized linear model
From
Joe Canner <[email protected]>
To
"[email protected]" <[email protected]>
Subject
RE: st: regression using generalized linear model
Date
Tue, 11 Mar 2014 20:28:48 +0000
Aiden,
Apparently my memory is rusty on -anova- as well. To treat an independent variable in -anova- as continuous, precede it with "c.". So, assuming that variable -a- has been appropriately converted to numeric your command would look something like:
anova x v#y#y c.u#c.u t a#b
Of course, the interaction between two continuous variables can also be accomplished by calculating their product first:
gen u2=u*u
anova x v#y#y u2 t a#b
See -help fvarlist- for information on the various options for specify your independent variables in an ANOVA (or elsewhere).
Regards,
Joe
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Trung (Aidan) Nguyen
Sent: Tuesday, March 11, 2014 3:06 PM
To: statalist
Subject: Re: st: regression using generalized linear model
Thanks Joe and Nick,
I used the encode command to turn the class variable 'a' into a
numeric value. However, for anova command to work, all the dependent
variables must be of integer value. If I assigned integer values for
all the dependent variables, then it would not lead me to the same
results I get from the GLM command in SAS. Yes, I did use the # for
the interaction effects in my STATA code. Would you suggest the glm
command in STATA?
x is the dependent var
a and b are the classification effects
Thanks.
On Tue, Mar 11, 2014 at 12:51 PM, Joe Canner <[email protected]> wrote:
>
> Actually, Aidan provides us with most of the answer in his post. He indicates that variable -a- is a "string character" and that -u- "contains non integer and negative values".
>
> Nick has suggested a fix for string variables (-encode-). -destring- may also work. I don't remember enough about PROC GLM to know how u*u should be translated into Stata. If the asterisk is an interaction, perhaps a hash(#) would work better in Stata.
>
> Incidentally, how did Aidan get the asterisks to work at all in Stata? Is that new in version 13?
>
> Joe
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
> Sent: Tuesday, March 11, 2014 2:40 PM
> To: [email protected]
> Subject: Re: st: regression using generalized linear model
>
> I've never used SAS but I have used Stata [NB].
>
> But the message does explain the problem, which may be why no-one
> answered this first time this was asked.
>
> At least one of your variables -v y u t a b- contains something other
> than integers. So,
>
> . codebook v y u t a b
>
> to see which variable(s) don't come up to scratch. Perhaps one is
> string. Even if SAS permits string predictors (I don't know its
> terminology), Stata expects you to -encode- string variables before
> using them in -anova-.
>
> (Please note our policy on repeating posts. It's best to wonder why a
> post didn't get answered, and revise it, and not to seem too
> impatient.)
>
> Nick
> [email protected]
>
> On 11 March 2014 18:28, Aidan Trung Nguyen <[email protected]> wrote:
>
> > I'm trying to write the STATA equivalent of the followingSAS statement:
> >
> > proc glm data=datasetclass a b model x = v*y*y u*u t a*b
> > weight w
> > output out = outputdataset
> >
> >
> > a is a string character
> > b, x, v, y, u, t are numeric
> > u contains non integer and negative values
> >
> > I tried the below command but without success:anova x v*y*y u*u t a*b
> >
> > error message : factor variables may not contain non integervalues Any guidance is much appreciated.
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/