# Assignment Help

Hey, I'm doing a University assignment that involves using R studio and I feel stuck. Below firstly is the question I'm currently doing and the R output, any help would be very much appreciated.

Cheers, Daniel

Based on past experience with clinical use of a hypertension drug, a drug company expects that, if the drug is administered under medical supervision to 4 randomly selected hypertension patients who were previously untreated, the number whose hypertension is brought under control will follow this distribution:
No. brought under control 0, 1, 2, 3, 4
Proportion .004, .047, .211, .422, .316
The company supplied the drug to 128 doctors who agreed to use it on their next 4 hypertensive patients. 21 of the doctors were successful with all 4 patients, 63 were successful with 3, 34 succeeded with just 2 patients, and 9 succeeded with only 1 of their next 4 patients. (Here “succeeded” means “brought the patient’s hypertension under control”.) Are these results consistent with the distribution of successes expected by the company? Evaluate with a suitable hypothesis test at 5% significance level, taking care to evaluate and address any concerns over the assumptions.

``````Obs=c( 1, 9, 34, 63, 21)
> props=c(.004, .047, .211, .422, .316)
> Xsq=chisq.test(Obs, p=props)
Warning message:
In chisq.test(Obs, p = props) : Chi-squared approximation may be incorrect
> Xsq\$observed
[1]  1  9 34 63 21
> Xsq\$expected
[1]  0.512  6.016 27.008 54.016 40.448
> Xsq\$residuals
[1]  0.6820007  1.2165919  1.3454117  1.2223865 -3.0579221
> Xsq

Chi-squared test for given probabilities

data:  Obs
X-squared = 14.6, df = 4, p-value = 0.005606``````

You've been able to produce output with R in relation to your homework task.
Appreciate your sharing your code and data, that allows me to reproduce your work so far.

Can you be more specific about what you want additional help with ? It seems like you might be asking non-R statistics advice, but perhaps you can clarify

I’m unsure if the warning message in the R output is due to a mistake in the script input or is something I need to take into account when analyzing the data.

https://vulstats.ucsd.edu/notes/nhst-chi-squared.html

In practice, if you have particularly small counts and need to test against some theoretical distribution, I suggest doing resampling to calculate the exact null hypothesis distribution, and compute a p-value without relying on the questionable normal approximation under low cell counts (we will cover variations of this technique in the second semester). Fortunately, R’s `chisq-test` function warns you when cell counts are small, and suggests doing exactly this. To carry out this Monte Carlo simulation to get a p-value without assuming asymptotically normal behavior from small cell counts, set `simulate.p.value=TRUE` in `chisq.test` .

``Xsq <- chisq.test(Obs, p=props,simulate.p.value = TRUE)``

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.