Discrete time model
p.vartical$agestart2<-(p.vartical$agestart)*(p.vartical$agestart)
fitv<-glm(smokstatustran~bs(agestart)+Sport
, data=p.vartical, family=binomial)
summary(fitv)
##
## Call:
## glm(formula = smokstatustran ~ bs(agestart) + Sport, family = binomial,
## data = p.vartical)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.0644 -0.6578 -0.5748 -0.5079 2.7043
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.8410 0.1157 -7.272 3.55e-13 ***
## bs(agestart)1 -4.7200 0.2316 -20.383 < 2e-16 ***
## bs(agestart)2 4.2762 0.2540 16.837 < 2e-16 ***
## bs(agestart)3 -6.3654 0.3305 -19.259 < 2e-16 ***
## SportHard 0.3108 0.1123 2.766 0.00567 **
## SportModerate 0.4991 0.1053 4.740 2.14e-06 ***
## SportNo 0.5692 0.1086 5.243 1.58e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 22948 on 24568 degrees of freedom
## Residual deviance: 22465 on 24562 degrees of freedom
## (16591 observations deleted due to missingness)
## AIC: 22479
##
## Number of Fisher Scoring iterations: 4
sumt<-data.frame(summary(fitv)$coef); sumt$HR<-round(exp(sumt[,1]), 3)
sumt
## Estimate Std..Error z.value Pr...z.. HR
## (Intercept) -0.8409683 0.1156510 -7.271602 3.552487e-13 0.431
## bs(agestart)1 -4.7200267 0.2315684 -20.382858 2.373827e-92 0.009
## bs(agestart)2 4.2761778 0.2539709 16.837275 1.300918e-63 71.965
## bs(agestart)3 -6.3653531 0.3305093 -19.259228 1.181265e-82 0.002
## SportHard 0.3107613 0.1123393 2.766274 5.670083e-03 1.364
## SportModerate 0.4990813 0.1052998 4.739623 2.141159e-06 1.647
## SportNo 0.5691790 0.1085579 5.243092 1.579079e-07 1.767
library(sjPlot)
## Registered S3 methods overwritten by 'lme4':
## method from
## cooks.distance.influence.merMod car
## influence.merMod car
## dfbeta.influence.merMod car
## dfbetas.influence.merMod car
## #refugeeswelcome
library(sjmisc)
library(sjlabelled)
tab_model(fitv)
## Profiled confidence intervals may take longer time to compute. Use 'df_method="wald"' for faster computation of CIs.
|
|
smokstatustran
|
|
Predictors
|
Odds Ratios
|
CI
|
p
|
|
(Intercept)
|
0.43
|
0.34 – 0.54
|
<0.001
|
|
agestart [1st degree]
|
0.01
|
0.01 – 0.01
|
<0.001
|
|
agestart [2nd degree]
|
71.96
|
43.84 – 118.64
|
<0.001
|
|
agestart [3rd degree]
|
0.00
|
0.00 – 0.00
|
<0.001
|
|
Sport [Hard]
|
1.36
|
1.10 – 1.71
|
0.006
|
|
Sport [Moderate]
|
1.65
|
1.35 – 2.03
|
<0.001
|
|
Sport [No]
|
1.77
|
1.43 – 2.20
|
<0.001
|
|
Observations
|
24569
|
|
R2 Tjur
|
0.020
|
## Warning: In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
## extra argument 'family' will be disregarded
##
## Attaching package: 'dplyr'
## The following object is masked from 'package:nlme':
##
## collapse
## The following object is masked from 'package:sjlabelled':
##
## as_label
## The following object is masked from 'package:car':
##
## recode
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Warning in bs(agestart, degree = 3L, knots = numeric(0), Boundary.knots =
## c(12, : some 'x' values beyond boundary knots may cause ill-conditioned bases
## Warning: Removed 32 row(s) containing missing values (geom_path).

##
## Attaching package: 'table1'
## The following objects are masked from 'package:base':
##
## units, units<-
|
Overall (N=24569) |
| Gender |
|
| Male |
11054 (45.0%) |
| Female |
13515 (55.0%) |
| Race |
|
| White |
11371 (46.3%) |
| Black |
7529 (30.6%) |
| Hispanic |
5456 (22.2%) |
| Mixed |
213 (0.9%) |
| Sport |
|
| Daily |
853 (3.5%) |
| Hard |
3521 (14.3%) |
| Moderate |
14212 (57.8%) |
| No |
5983 (24.4%) |
## Warning: In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
## extra argument 'family' will be disregarded
## Warning: In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
## extra argument 'family' will be disregarded
|
|
Model1
|
Model2
|
|
Coeffcient
|
Estimates
|
Conf. Int (95%)
|
P-Value
|
Estimates
|
Conf. Int (95%)
|
P-Value
|
|
(Intercept)
|
0.13
|
0.11 – 0.16
|
<0.001
|
0.17
|
0.15 – 0.20
|
<0.001
|
|
Sport: Hard
|
0.03
|
0.00 – 0.06
|
0.033
|
0.03
|
-0.00 – 0.05
|
0.075
|
|
Sport: Moderate
|
0.05
|
0.02 – 0.07
|
0.001
|
0.04
|
0.01 – 0.06
|
0.008
|
|
Sport: No
|
0.05
|
0.03 – 0.08
|
<0.001
|
0.05
|
0.02 – 0.07
|
0.001
|
|
Gender: Female
|
|
|
|
-0.03
|
-0.04 – -0.02
|
<0.001
|
|
Race: Black
|
|
|
|
-0.04
|
-0.05 – -0.03
|
<0.001
|
|
Race: Hispanic
|
|
|
|
-0.02
|
-0.03 – -0.00
|
0.015
|
|
Race: Mixed
|
|
|
|
-0.00
|
-0.05 – 0.05
|
0.998
|
|
Observations
|
24569
|
24569
|
|
R2 / R2 adjusted
|
0.001 / 0.001
|
0.005 / 0.004
|