Publications by Daniel
House price prediction part 2
Read in data # load packages library(tidyverse) ## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ── ## ✔ dplyr 1.1.1 ✔ readr 2.1.4 ## ✔ forcats 1.0.0 ✔ stringr 1.5.0 ## ✔ ggplot2 3.4.2 ✔ tibble 3.2.1 ## ✔ lubridate...
1401 sym R (19021 sym/57 pcs) 8 img
House price prediction week3
Read in data # load packages library(tidyverse) ## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ── ## ✔ dplyr 1.1.1 ✔ readr 2.1.4 ## ✔ forcats 1.0.0 ✔ stringr 1.5.0 ## ✔ ggplot2 3.4.2 ✔ tibble 3.2.1 ## ✔ lubridate...
1093 sym R (14362 sym/46 pcs) 6 img
Fit regression model for a fan-shaped relation
Data and plot x = (runif(5000)) y = x*(1+rnorm(5000,0,0.1)) plot(x,y,cex=.5,pch=21) mod=lm(y~x) summary(mod) ## ## Call: ## lm(formula = y ~ x) ## ## Residuals: ## Min 1Q Median 3Q Max ## -0.26137 -0.02603 0.00040 0.02539 0.35340 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ...
461 sym 20 img
Comparison of mixed models in SAS and R- covariance structure
The comparison of output of SAS AND R for mixed model Data process library(nlme) setwd("C:\\Users\\hed2\\OneDrive - National Institutes of Health\\Mixed model by SAS and R") head(Orthodont) ## Grouped Data: distance ~ age | Subject ## distance age Subject Sex ## 1 26.0 8 M01 Male ## 2 25.0 10 M01 Male ## 3 29.0 12 ...
429 sym R (4864 sym/13 pcs) 1 tbl
3 Standardization and G formula
Standardization and G formula The standardized mean is the weighted average of the conditional means in each stratum, and the weights are the probability of occurrence Pr [L = l ] in each stratum. But in high-dimensional data—such as our smoking cessation example—it is impossible for us to estimate E[Y|A=1,C =0,L=l] in a nonparametric way. ...
3041 sym R (11330 sym/21 pcs)
1 Causal inference introduction
Introduction Definition If all people are in the treatment/non-treatment group, the overall causal effect is calculated. The mean of the causal effect is E(Ya1-Ya0). The target trials are one of the cores of the causal inference framework. Randomized experiments For group A, p(Y=1|A=0) is equal to p(Y=1|A=0) for group B, so for a perfect ra...
4149 sym
2 IP Weighting
Reference book: Hernán, Miguel A, and James M Robins. 2020. Causal Inference: What If. Boca Raton: Chapman & Hall/CRC. Inverse probability of treatment weight Data preparation Load data ## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ── ## ✔ dplyr ...
2228 sym R (27891 sym/85 pcs)
Which covariate should be adjusted
Which covariate should be adjusted In this example, we assume to investigate the causality between smoking and mortality: whether smoking will more likely cause mortality. We collect the following variables. Smoking is the exposure, Mortality is the outcome, and others are patient confounders. Then, we connect these knots by directed arrow acco...
1223 sym 3 img
Matching and Weighting analyses
Matching and Weighting analyses Not propensity score or inverse probability of treatment weighting. It also can apply to 1 imputed dataset if letting m=1. Matching set.seed(123) # load dataset library(mice) ## ## Attaching package: 'mice' ## The following object is masked from 'package:stats': ## ## filter ## The following objects are ...
1490 sym R (10739 sym/55 pcs) 3 img
How to use subscripts/superscripts for a figure
How to use subscripts/superscripts # first plot I would like to have a subscript 1 and for the scond one a subscript 2 # One solution is to use bquote(). Use .() within bquote to get the value of objects or expressions. plotf = function(title=expression("Test"~a )){ plot(cars) title(title) } foo = expression(a[1], a^-2) layout(matrix(...
137 sym R (2048 sym/13 pcs) 4 img