R Markdown
Hi folks
I'm trying to do a post-hoc test with the glht() function from the multcomp package. I receive an unexptected symbol error and I don't understand why.
Please find the example of the dataframe which should reproduce the error. It's my first question here and please forgive me if I didn't get the reprex perfect.
Many thanks in advance!
df1 <- data.frame(credit_amount = c(1169,5951,20960,78820,4870,9055,2835,6948,3059,5234),
job = as.factor(c("skilled","skilled",
"unskilled resident","skilled","skilled",
"unskilled resident","skilled",
"high qualif/self emp/mgmt",
"unskilled resident",
"high qualif/self emp/mgmt"))
)
lm.credit <- lm(credit_amount ~ job, data = df1)
library(multcomp)
ph.test.1 <- glht(model = lm.credit,
linfct = mcp(job = c("unskilled resident - skilled = 0")))
summary(ph.test.1)
Harlekin:
unskilled resident
Eliminate the blanks:
library(multcomp)
#> Loading required package: mvtnorm
#> Loading required package: survival
#> Loading required package: TH.data
#> Loading required package: MASS
#>
#> Attaching package: 'TH.data'
#> The following object is masked from 'package:MASS':
#>
#> geyser
df1 <- data.frame(
credit_amount = c(1169, 5951, 20960, 78820, 4870, 9055, 2835, 6948, 3059, 5234),
job = as.factor(c(
"skilled", "skilled",
"unskilled_resident", "skilled", "skilled",
"unskilled_resident", "skilled",
"high qualif/self emp/mgmt",
"unskilled resident",
"high qualif/self emp/mgmt"
))
)
lm.credit <- lm(credit_amount ~ job, data = df1)
ph.test.1 <- glht(
model = lm.credit,
linfct = mcp(job = c("unskilled_resident - skilled = 0"))
)
summary(ph.test.1)
#>
#> Simultaneous Tests for General Linear Hypotheses
#>
#> Multiple Comparisons of Means: User-defined Contrasts
#>
#>
#> Fit: lm(formula = credit_amount ~ job, data = df1)
#>
#> Linear Hypotheses:
#> Estimate Std. Error t value Pr(>|t|)
#> unskilled_resident - skilled == 0 -3722 23165 -0.161 0.878
#> (Adjusted p values reported -- single-step method)
Created on 2021-01-03 by the reprex package (v0.3.0.9001)
system
Closed
January 24, 2021, 7:01pm
3
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.