Question

<<Using R exercise>> Q. Consider the data in anorexia in the MASS library. Find a 98%...

<<Using R exercise>>

Q. Consider the data in anorexia in the MASS library. Find a 98% confidence interval for the variable Prewt and Postwt.

Homework Answers

Answer #1

I am writing down the code here which you can run to get the answer.

I have used the following formula for confidence interval from the literature.

#######Following is the code.

confidence=function(data,level)

{

m=mean(data)

s=sd(data)

n=length(data)

t=qt((1-level)/2,df=n-1,lower.tail=FALSE)

lcl=m-(s/sqrt(n))*t

ucl=m+(s/sqrt(n))*t

return(paste("(",lcl,",",ucl,")"))

}

library(MASS)

dat=anorexia

data1=anorexia$Prewt

data2=anorexia$Postwt

conf_lvl=0.98

##Confidence Interval for Prewt

confidence(data=data1,level=conf_lvl)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using ToothGrowth Data in R (data found using R program by library(datasets) -> data("ToothGrowth") ), Assume...
Using ToothGrowth Data in R (data found using R program by library(datasets) -> data("ToothGrowth") ), Assume that if “len” is above 20, it is classified as “HIGH”; and ”LOW”, otherwise. Ignore ‘dose’, and determine whether there is a significant difference in the proportions of the two groups classified as “HIGH” using a suitable test and a 95% confidence interval
Consider the anorexia dataset in the MASS package. This data considers two treatments for anorexia, one...
Consider the anorexia dataset in the MASS package. This data considers two treatments for anorexia, one based on Cognitive Behavorial Treatment (CBT) sessions from a professional therapist and another based on family oriented treatment sessions (FT). The Treat variable is a factor with three levels: Cont (control, no treatment), CBT, and FT. For each subject two weights (in lbs) were measured, one before (Prewt) and one after (Postwt) treatment. (a) Create a new variable, Outcome, that indicates if the post-weight...
For the `Melanoma` (**MASS**) data set, use `prop.test()` to find a 99% confidence interval for the...
For the `Melanoma` (**MASS**) data set, use `prop.test()` to find a 99% confidence interval for the difference in proportion of male and female patients with an ulcer. Please use R code data set is melanoma in the library mass.
A student was asked to find a 98% confidence interval for widget width using data from...
A student was asked to find a 98% confidence interval for widget width using data from a random sample of size n = 25. Which of the following is a correct interpretation of the interval 14.2 < μ < 24.4? Check all that are correct. There is a 98% chance that the mean of a sample of 25 widgets will be between 14.2 and 24.4. With 98% confidence, the mean width of all widgets is between 14.2 and 24.4. The...
Using R and install.packages("MASS"), library(MASS) 1. Generate the following vector using at least two methods. 0,...
Using R and install.packages("MASS"), library(MASS) 1. Generate the following vector using at least two methods. 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4 2. Generate the following vector. Apple1, Banana2, Orange3, Cranberry4, Watermelon5 3. Generate the following vector using the “rep” function. a, a, b, b, c, c, a, a, b, b, c, c 4. In vector y = (8, 3, 5, 7, 6, 6, 8, 9, 2, 3, 9, 4, 10, 4, 11), which elements of y contains...
Using R or RStudio After loading the data crime2005 data set from the library smss, use...
Using R or RStudio After loading the data crime2005 data set from the library smss, use (non-robust) linear regression to model the crime rate per 10,000 people (VI2) as a function of the percentage of the population that live in metropolitan areas (ME) and the percentage of the population that live below the poverty line (PO). Enter your R code below.
(Use the R studio to find the answer.) 5. Consider the Batting data frame from the...
(Use the R studio to find the answer.) 5. Consider the Batting data frame from the Lahman library. a) How many observations and how many variables does Batting contain? (b) Use filter from the dplyr library to make a new data frame with just the information from yearID 2015. How many observations does this contain? (c) Who had the most Bases on Balls (BB) in 2015? (You can just give the player ID) (d) How many players had more than...
Consider two independent random samples with the following results: n1=601pˆ1=0.41   n2=578pˆ2=0.73 Use this data to find...
Consider two independent random samples with the following results: n1=601pˆ1=0.41   n2=578pˆ2=0.73 Use this data to find the 98% confidence interval for the true difference between the population proportions. Copy Data Step 1 of 3 :   Find the point estimate that should be used in constructing the confidence interval. Step 2 of 3 : Find the value of the standard error. Round your answer to three decimal places. Step 3 of 3: Construct the 98% confidence interval. Round your answers to...
r code Load the “star” data from the “faraway” package, and model “temp” using “light”. library(faraway)...
r code Load the “star” data from the “faraway” package, and model “temp” using “light”. library(faraway) data(star) fit = lm(temp ~ light, data = star) One may also suspect that the residuals (use all the data) follow a t distribution instead of normal. Using the same logic that we produced the QQ plot for comparing to the normal distribution, produce a QQ plot for comparing to a t distribution. You need to decide the degrees of freedom yourself (consider df...
Consider two independent random samples with the following results: n1=528x1=370n1=528x1=370   n2=743x2=201n2=743x2=201 Use this data to find...
Consider two independent random samples with the following results: n1=528x1=370n1=528x1=370   n2=743x2=201n2=743x2=201 Use this data to find the 98%98% confidence interval for the true difference between the population proportions. Copy Data Step 1 of 3 :   Find the point estimate that should be used in constructing the confidence interval. Round your answer to three decimal places. Step 2 of 3 : Find the margin of error. Round your answer to the sixth decimal place. Step 3 of 3 : Find the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT