On Tue, 2010-08-17 at 10:29 +0800, elaine kuo wrote:> Dear List,
>
>
>
> Some independent variable were missing in calculation using lm and glm
> (gaussian).
>
> (X= Y1+Y2+..+Y16, Independent number: 16 variable)
What's this? This isn't valid R code. If it is `Elaine Kuo model
notation` how on earth do you expect the readers of this list to be
certain what you mean? This is why we ask for reproducible R code!
> However, those variables did work well in cor(X, Y) respectively.
So, are you asking why weren't the variables included in the model when
cor(X,Y) include those variables? How would we know, you haven't shown
us the code you used to fit the model.
If X is a data.frame of predictors variables and Y the response vector,
then
lm(Y ~ ., data = X)
will include all variables from X to model response Y.
If you send a reproducible example or full code plus output of str(OBJ)
where OBJ are your data objects, then I'll try to help further.
> str(dataframe) was also run to ensure that the variables were all numbers.
>
> Moreover, the missing variables were different in lm and glm.
>
> In lm, 3 factors were not taken into consideration.
>
> In glm, only one of them was omitted.
>
> (attached 2 shots)
Attachments are stripped unless they are of a small set of approved
formats. Read the posting guide to see what is allowed.
> Please kindly advise whether further info is in need to solve the issue.
Err, yes. If you are getting such inconsistencies then you need to solve
the issue as it likely points to you doing something wrong in the way
you are using R.
BUT! Give us something concrete to work with. I won't reply if you don't
read and follow the posting guide; life is too short to spend it
guessing how you went wrong.
HTH
G
> Also, if similar problems have been encountered, please kindly share your
> experience.
>
> Thank you.
>
>
> Elaine
>
>
>
>
>
> Code
>
> rm(list=ls())
>
> library(MuMIn)
>
>
>
> datam
<-read.csv("c:/migration/Mig_ratio_20100817.csv",header=T,
> row.names=1)
>
>
>
> dim(datam)
>
> datam[1,]
>
>
>
> # original regression model (16 indep. variables)
>
> Mig.lm
>
<-lm(datam$SummerM_ratio~datam$temp_ran+datam$temp_mean+datam$temp_max+datam$temp_min+datam$evi_ran+datam$evi_mean+datam$evi_max+datam$evi_min+datam$prec_ran+datam$prec_mean+datam$prec_max+datam$prec_min+datam$topo_var+datam$topo_mean+datam$coast+datam$Iso_index_0808,data=datam)
>
>
>
> summary(mig.lm)
>
>
>
> mig.glm
>
<-glm(datam$SummerM_ratio~datam$temp_ran+datam$temp_mean+datam$temp_max+datam$temp_min+datam$evi_ran+datam$evi_mean+datam$evi_max+datam$evi_min+datam$prec_ran+datam$prec_mean+datam$prec_max+datam$prec_min+datam$topo_var+datam$topo_mean+datam$coast+datam$Iso_index_0808,data=datam,family=gaussian)
>
>
>
> summary(mig.glm)
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%