Showing posts with label R. Show all posts
Showing posts with label R. Show all posts

Wednesday, February 6, 2013

Weighted Logistic Regression in R, SPSS, Stata

In R:

We will use mtcars dataset to illustrate.  (R version 2.5.1)

> data(mtcars)
> mtcars <- as.data.frame(mtcars)
> mtcars$p <- runif(nrow(mtcars)) # create weights
> mtcars2 <- mtcars[c("am", "hp", "wt", "p")]
> head(mtcars2)
                  am  hp    wt         p
Mazda RX4          1 110 2.620 0.8901532
Mazda RX4 Wag      1 110 2.875 0.4601596
Datsun 710         1  93 2.320 0.9779983
Hornet 4 Drive     0 110 3.215 0.6889322
Hornet Sportabout  0 175 3.440 0.3856835
Valiant            0 105 3.460 0.1209667

Wednesday, July 20, 2011

Nested case-control study

Nested case-control study can be described as follows: for a particular disease, all the patients that become diseased in a given cohort are labeled as "cases". Then corresponding to each "case", a pre-specified number (say, 4) of "controls" or healthy subjects (at the time when disease occurred for the case) are matched (irrespective of whether these healthy subjects became case at a later period). This design is interesting because cost can be minimized at the expense of negligible statistical inefficiencies compared to considering whole cohort. More can be found here.

Wednesday, January 26, 2011

Conditional estimates for OR

When two independent samples from separate population are collected, a product binomial likelihood can be used. However, conditioning on margins, a different formulation is achieved, as follows (shai being population OR):

Comparing Risks

To evaluate whether an exposure is at all contributing to risk of disease, the simplest form of comparison is as follows:
x1 ~ Binomial(n1, pi1)
x2 ~ Binomial(n2, pi2)

Transformation for CI construction

To facilitate construction of confidence intervals, it is common to transform parameters. Delta method can he used to derive the approximate variance in that case. Here is the general theory for logarithmic transformed parameters:

Inference for proportions in small samples

Large sample approximations do not work well in a small sample setting. Exact tests have to be developed for better estimation in that case.

Since we know X (positive cell count for response) follows binomial, without making normal approximation, we can go for exact inference, by calculating the confidence intervals from the quantiles of a binomial distribution.

Inference for proportions in a large sample

From the following 2x2 table, we want to infer about the population risks:



outcome



+
-
Marginal total
exposure
+
a
b
n1
-
c
d
n2
Marginal total

m1
m2
N


Sunday, October 17, 2010

Download and Install R

In the following video, the instruction of downloading R and installing it in your system is given. This video is for newbies only.