我在R中运行摘要(lm(...))函数.当我打印系数时,我得到除最后一个变量之外的所有变量的估计值.最后一个变量我得到"NA".
我尝试用另一列切换最后一列数据,再次,最后一列中的任何内容得到"NA",但其他一切都得到了估计.
关于数据的一点点:我有大约5个变量,每行有数据,然后我有12个季节变量,例如,如果月份是1月份,1月份每天都有1,否则为0.对于2月变量,如果月份是2月份则为1,否则为0,依此类推.有谁知道在系数估算的最后一列会产生"NA"的是什么?所以我第一次运行它时,它是12月虚拟变量的系数.是因为我的每月虚拟变量?谢谢
这是我可重复的例子.
dat<- data.frame(
one<-c(sample(1000:1239)),
two<-c(sample(200:439)),
three<-c(sample(600:839)),
Jan<-c(rep(1,20), rep(0,220)),
Feb<-c(rep(0,20),rep(1,20),rep(0,200)),
Mar<-c(rep(0,40),rep(1,20),rep(0,180)),
Apr<-c(rep(0,60),rep(1,20),rep(0,160)),
May<-c(rep(0,80),rep(1,20),rep(0,140)),
Jun<-c(rep(0,100),rep(1,20),rep(0,120)),
Jul<-c(rep(0,120),rep(1,20),rep(0,100)),
Aug<-c(rep(0,140),rep(1,20),rep(0,80)),
Sep<-c(rep(0,160),rep(1,20),rep(0,60)),
Oct<-c(rep(0,180),rep(1,20),rep(0,40)),
Nov<-c(rep(0,200),rep(1,20),rep(0,20)),
Dec<-c(rep(0,220),rep(1,20)
)
attach(dat)
summary(lm(one ~ two + three + Jan + Feb +
Mar + Apr + May + Jun + Jul + Aug + Sep + Oct + Nov + Dec))
Run Code Online (Sandbox Code Playgroud) r ×1