Posts

Module 12 Assignment

Image
Daniel Tafmizi Lis 4273 Dr. Ajani  April 6, 2024 Module 12 Assignment Charge<-c(31.9,27,31.3,31,39.4,40.7,42.3,49.5,45,50,50.9,58.5,39.4,36.2,40.5,44.6,46.8,44.7,52.2,54,48.8 ,55.8,58.7,63.4) #creates a list of all charges. Chargetimeseries <-ts(Charge) #the 24 charges are arranged in a time series of 24 values. Chargetimeseries <-ts(Charge, frequency = 12, start=c(2012,1), end = c(2013, 12)) #applies the time span ?ts  Time series function consists of (data, start: natural time unit, frequency: # of obs per time unit) Data is charge, frequency is 12 observations per 1 year, start is 2012 with time unit being 1 year plot(Chargetimeseries)  The visualization shows that there were more charges in 2013 than 2012. Charges tend to increase as the year progresses. We should use Holt-Winters exponential smoothing because we see an increasing trend and seasonality. ?HoltWinters Chargeforecast<-HoltWinters(Chargetimeseries) plot(Chargeforecast) Chargeforecast Holt-Wint...

Module 11 Assignment

Image
Daniel Tafmizi Lis 4273 Dr. Ajani  March 24, 2024 Module 11 Assignment 1. ashina$subject <- factor(1:16)  attach(ashina)  act <- data.frame(vas=vas.active, subject, grp = 2)  plac <-data.frame(vas=vas.plac, subject, grp = 1)    model <- glm(unlist(act)~unlist(plac)) Coefficients: (Intercept) unlist(plac) -13.609 1.236 Degrees of Freedom: 47 Total (i.e. Null); 46 Residual Null Deviance: 95890 Residual Deviance: 61180 AIC: 485.4  plot(model) The model shows us that the active treatment patients responded better than the placebo treatment patients. I wish I could say more, but to be completely honest; I am very confused.  2. a <- gl(2, 2, 8) b <- gl(2, 4, 8) x <-- 1:8 y <- c(1:4, 8:5) z <- rnorm (8) model.matrix(z~a:b) (Intercept) a1:b1 a2:b1 a1:b2 a2:b2 1 1 1 0 0 0 2 1 1 0 0 0 3 1 0 1 0 0 4 1 0 1 ...

Module 10 Assignment

Daniel Tafmizi Lis 4273 Dr. Ajani  March 24, 2024 Module 10 Assignment 9.1.  library(ISwR) data <- (cystfibr) x <- lm(formula = cystfibr$pemax ~ age + weight + bmp + fev1, data=cystfibr) anova(x)          Analysis of Variance Table Response: cystfibr$pemax            Df  Sum Sq Mean Sq F value    Pr(>F)     age        1 10098.5 10098.5 18.4385 0.0003538 *** weight     1   945.2   945.2  1.7258 0.2038195     bmp        1  2379.7  2379.7  4.3450 0.0501483 .   fev1       1  2455.6  2455.6  4.4836 0.0469468 *   Residuals 20 10953.7   547.7    With the given model, we are testing the statistical significance between pemax to the other groups. Given the low P-values, we can say that age and fev1 are significa...

Module 9 Assignment

Daniel Tafmizi Lis 4273 Dr. Ajani  March 10, 2024 Module 9 Assignment # 1. #Your data.frame is assignment_data <- data.frame( Country = c("France","Spain","Germany","Spain","Germany", "France","Spain","France","Germany","France"), age = c(44,27,30,38,40,35,52,48,45,37), salary = c(6000,5000,7000,4000,8000), Purchased=c("No","Yes","No","No","Yes", "Yes","No","Yes","No","Yes")) #Generate simple table in R that consists of four rows: Country, age, salary and purchased. install.packages("data.table")        library(data.table) table <- setDT(assignment_data) #turns data frame into table table Country   age salary Purchased     <char> <num>  <num>    <char> 1:  France    44   6000        No 2:   Spain    27   5000       Yes 3: Germany    30   7000       ...

Module 8 Assignment

 Daniel Tafmizi Lis 4273 Dr. Ajani  March 3, 2024 Module 8 Assignment Question 1) We are comparing three groups by stress level, I need a qualitative(group name)and quantitative(level data) set Null Hypothesis: The means of each group are the same Alternative Hypothesis: at least one mean is different from the rest groups <- rep(c("High", "Mod", "Low"), each = 6) #Creates vector where each variable holds 6 data meansStress <- c(c(10,9,8,9,10,8),c(8,10,6,7,8,8),c(4,6,6,4,2,2)) #combines stress data datafr <- data.frame(groups, meansStress)  ggplot(datafr) + aes(x=groups, y=meansStress) + geom_jitter() #cool visual, checks that R is processing data correctly fit <- aov(meansStress ~ groups, data = datafr) #runs anova analysis summary(fit)               Df Sum Sq Mean Sq F value   Pr(>F)     groups       2  82.11   41.06   21.36 4.08e-05 *** Residuals...

Module 7 Assignment

Image
Daniel Tafmizi Lis 4273 Dr. Ajani  February 23, 2024 Module 7 Assignment Question 1) x <- c(16, 17, 13, 18, 12, 14, 19, 11, 11, 10) y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48) Y = a + bX +e 1.1 Define the relationship model between the predictor and the response variable: model <- lm(y~x)  R equation for x,y relationship. Y is the target, x is the predictor   Relationship Model :  Y = 19.206 + 3.269X, RSE =10.48 the relationship has a positive correlation 1.2 Calculate the coefficients? summary(model)  gives information about the relationship model regression coefficient = 3.269, intercept coefficient = 19.206 question 2) discharge <- c(3.600,1.800,3.333,2.283,4.533,2.883) waiting <- c(79,54,74,62,85,55) visit <- data.frame(discharge, waiting) model2 <- lm(discharge ~ waiting, data=visit) summary(model2) Relationship Model : Y= -1.53317 + 0.06756X, RSE = 0.4724, the relationship has a positive correlation coeffs = coefficients(model2); co...

Module 6 assignment

Image
Daniel Tafmizi Lis 4273 Dr. Ajani  February 18, 2024 Module 6 Assignment #A) Consider a population consisting of the following values, which represents the number of  #ice cream purchases during the academic year for each of the five housemates.8, 14, 16, 10, 11 iceCream <- c(8,14,16,10,11) #Creates numerical vector #b. Select a random sample of size 2 out of the five members.  #See the example I used in my Power-point presentation slide # 13. randomSample <- sample(iceCream, 2) #Gets random sample of two values 10 & 8 were chosen # c. Compute the mean and standard deviation of your sample. mean(randomSample) # mean of sample = 9 sd(randomSample) # standard deviation of sample = 1.414214 mean(iceCream) # mean of population = 11.8 sd(iceCream) # standard deviation of population = 3.193744 #d. Compare the Mean and Standard deviation of your sample to the entire population of this set (8,14, 16, 10, 11). # The random sample taken chose the two lowest values of the ...