'Why does lm generate NA for each independent variable?
I tried to make a linear regression with the lm function, but the output is NA for every independent variable. The dataframe is numeric.
I have already tried to change the independent variable and only use one dependent variable, but the result was the same.
# 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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|