我尝试使用lm函数进行线性回归,但是每个自变量的输出均为NA。数据框是数字的。
我已经尝试更改自变量,仅使用一个因变量,但是结果是相同的。
# Read csv file
gh_old_shorty <- read.csv(file.choose(), header=T, sep=";")
# make dataframe numeric
as.data.frame(lapply(gh_old_shorty, as.numeric))
# create linear regression
model1 <- lm(Year ~ Age + OfficeOfPresidency + MembersOfParliament +
Assembly + GovernmentOfficials + LocalGovernmentOfficials + JudgesAndMagistrates + FightingCorruption, data=gh_old_shorty, na.action = na.omit)
summary(model1)
Call:
lm(formula = Year ~ Age + OfficeOfPresidency + MembersOfParliament +
Assembly + GovernmentOfficials + LocalGovernmentOfficials +
JudgesAndMagistrates + FightingCorruption, data = gh_old_shorty,
na.action = na.omit)
Residuals:
ALL 1 residuals are 0: no residual degrees of freedom!
Coefficients: (8 not defined because of singularities)
Estimate Std. Error t value
(Intercept) 2007 NA NA
Age NA NA NA
OfficeOfPresidency NA NA NA
MembersOfParliament NA NA NA
Assembly NA NA NA
GovernmentOfficials NA NA NA
LocalGovernmentOfficials NA NA NA
JudgesAndMagistrates NA NA NA
FightingCorruption NA NA NA
Pr(>|t|)
(Intercept) NA
Age NA
OfficeOfPresidency NA
MembersOfParliament NA
Assembly NA
GovernmentOfficials NA
LocalGovernmentOfficials NA
JudgesAndMagistrates NA
FightingCorruption NA
Residual standard error: NaN on 0 degrees of freedom