Publications by Tasneem Zaihra
Poisson Model Univariate vs Multivariate
Multivariate Analysis mv.model = glm(hospitalizations ~ sex+cesd+age, data = HELPrct, family = "poisson") summary(mv.model) ## ## Call: ## glm(formula = hospitalizations ~ sex + cesd + age, family = "poisson", ## data = HELPrct) ## ## Deviance Residuals: ## Min 1Q Median 3Q Max ## -3.7643 -1.7065 -0.8024 0.1558 ...
232 sym 3 tbl
Chapter5 Computing Assignment
Exercise 5.1 You can create a function to evaluate the MC estimate of the integral \(\int_{0}^{\pi/3} sin(t) dt\) and compare your value with the exact integral value, i.e., 0.5. Also, you should be able to demonstrate that by taking larger samples we reduce the error of our estimation and thus have a better estimate to the true integral value. e...
1751 sym R (1987 sym/9 pcs)
Ch5 Computing Lab: Nuts and bolts of Simulation
loading Packages require(latticeExtra) require(mosaic) require(Hmisc) Example1: Simulating Sampling Distribution of Mean for three different sample sizes, n=5, n=25 and n=100 from expoential distribution with mean 5 and visualising it using boxplots lambda<-2 numsim<-100 mean5<-rep(0,numsim) mean25<-mean5 mean100<-mean5 for (i in 1:numsim){ m...
5782 sym R (11408 sym/38 pcs) 3 img
Ch2_CLT_Lab
Problem2: Data/Sample generated from Normal Distribution set.seed(1234) true_mean <- 0 true_var <- 1 n <- 10 reps <- 10 cat("For a normal distribution with a mean of", true_mean, "and a variance of", true_var, "\nWith n =", n, "we should obtain a sample mean of", true_mean, "and a sample variance of", true_var/n,"\n") ## For a normal distribution...
451 sym R (5125 sym/25 pcs) 13 img
ECDF_Quantiles
require(moaic) require(dplyr) The e.c.d.f. (empirical cumulative distribution function) Fn is a step function with jumps i/n at observation values, where i is the number of tied observations at that value. Missing values are ignored. or observations x= (x1,x2, … xn), Fn is the fraction of observations less or equal to t, i.e., \[ Fn(t) = #{xi <...
2033 sym R (3283 sym/27 pcs) 6 img
Introduction to R n RStudio by Dr. Zaihra part1
Using RMarkdown Text Text can be decorated with bold or italics. It is also possible to create links include mathematics like \(e=mc^2\) or \[y = \beta_0 + \beta_1 x_1 + \beta_2 x_2\] Be sure to put a space after the * when you are creating bullets and a space after # when creating section headers, but not between $ and the mathematical formul...
7130 sym R (10025 sym/99 pcs) 8 img
Nuts and Bolts of R and RStudio Part2
knitr settings to control how R chunks work. require(knitr) opts_chunk$set( tidy=FALSE, # display code as typed size=“small” # slightly smaller font for code ) The most important template is goal(y~x,data=mydata) What you want R to do is Goal : This determines the function to use(favstat, mean, SD, lm) What must R know to do that: This dete...
1451 sym R (3464 sym/41 pcs) 21 img
Merge_Create_Reorder_Categories
Creating a random data frame, with two columns a== factor with 5 levels and B is numeric coming from normal distribution. set.seed(1234) # to keep the random variables generated fixed for every rerun to trace errors df <- data.frame(a = LETTERS[sample(5, 15, replace=TRUE)], y = rnorm(15)) df ## a y ## 1 A 0.98340378 ## 2 D -0.622...
1418 sym R (7386 sym/32 pcs) 1 img
DownstateTalk
Chunk where you install and/or load all necessary packages Vitamin C example’s contingency table and chi-square test ski.reg<-matrix(c(31, 17, 109, 122), ncol=2, dimnames=list(Treatment=c("Placebo", "VitaminC"), Cold=c("Cold", "NoCold"))) ski.reg %>% kbl(caption = "French Skiers Regular") %>% kable_classic(full_width = F, html_font = "Camb...
457 sym R (1319 sym/9 pcs)
Categorical Graphs exploring Moderation
require(mosaicCore) require(mosaicData) require(ggplot2) Improting one of the many mosaic data https://cran.r-project.org/web/packages/mosaicData/mosaicData.pdf head(HELPrct) ## age anysubstatus anysub cesd d1 daysanysub dayslink drugrisk e2b female ## 1 37 1 yes 49 3 177 225 0 NA 0 ## 2 37 ...
412 sym R (3166 sym/7 pcs) 2 img