Use this tag for any *on-topic* question that (a) involves `R` either as a critical part of the question or expected answer, & (b) is not *just* about how to use `R`.

learn more… | top users | synonyms

30
votes
6answers
20k views

How to determine best cutoff point and its confidence interval using ROC curve in R?

I have the data of a test that could be used to distinguish normal and tumor cells. According to ROC curve it looks good for this purpose (area under curve is 0.9): My questions are: How to ...
4
votes
1answer
2k views

Getting fixed-effect only predictions from mixed model on new data in R

I would like to construct predictions for a mixed model (logistic via glmer) on a new data set using only the fixed effects, holding the random effects to 0. But I am having trouble setting up the ...
6
votes
2answers
433 views

How to sample from $\{1, 2, …, K\}$ for $n$ random variables, each with different mass functions, in R?

In R, I have an $N \times K$ matrix $P$ where the $i$'th row of $P$ corresponds to a distribution on $\{1, ..., K\}$. Essentially, I need to sample from each row efficiently. A naive implementation ...
5
votes
4answers
6k views

How can I compute Pearson's $\chi^2$ test statistic for lack of fit on a logistic regression model in R?

The likelihood ratio (a.k.a. deviance) $G^2$ statistic and lack-of-fit (or goodness-of-fit) test is fairly straightforward to obtain for a logistic regression model (fit using the ...
8
votes
1answer
5k views

Differences between PROC Mixed and lme / lmer in R - degrees of freedom

Note : this question is a repost, as my previous question had to be deleted for legal reasons. While comparing PROC MIXED from SAS with the function lme from the ...
2
votes
0answers
593 views

Parametric or non-parametric tests? … or transformation?

I am using R to examine the relationship between two variables in a small data set ($n=16$). My problem is that I'm not really sure how to handle the analysis (read: I'm in deeper waters than I've ...
0
votes
0answers
169 views

Nonparametric regression in R

I have a time series that appears slightly nonlinear but it's similar to a sin or cos modified by a constant. 1,0 2,2 3,1 4,0 5,5 is one example and 1,0 2,1 3,2 4,0 5,5 is another. Calculating the ...
6
votes
1answer
2k views

How to visualize both total counts of categories and proportions of subcategories in a plot?

Suppose I have samples drawn from categories A, B, C. Within those categories, I have subcategories d,e,f which are found in all 3 categories. I want to visualize how many samples I have form ...
3
votes
1answer
1k views

What are the differences between the linear regression and mixed models?

What are the key differences between the following two models? ...
12
votes
1answer
7k views

Why are rlm() regression coefficient estimates different than lm() in R?

I am using rlm in the R MASS package to regress a multivariate linear model. It works well for a number of samples but I am getting quasi-null coefficients for a particular model: ...
4
votes
1answer
204 views

Hypothesis testing: small timeseries changes

I have pairs of timeseries that are estimating the same quantity over the years. It is some survival data: number of "dead" subjects during the year over the number of total subjects at the beginning ...
0
votes
3answers
130 views

What tool can we use to assess if there are enough data?

Imagine some paired data ${(x_i,y_i)}_{i=1}^n$ representing the results of two different measurement methods and the question is about the quantification of the bias between the two methods. Let us ...
6
votes
4answers
14k views

Slope of a line given multiple points [closed]

I have data with a starting (y) value that sequentially increments/decrements as (x) time measured in days passes. I found this link for creating a linear regression of the data ...
6
votes
1answer
3k views

error in getting predictions from a lme object

I am trying to get predictions for observations from a lme object. This is supposed to be quite straightforward. Yet, since I am get different types of errors for different trials, it seems to me I ...
3
votes
1answer
697 views

How to plot the contribution of each regression coefficient in a model, with R?

I've fit a model with lm(), and I now want to analyze it to see where it's overfit, etc... I'm imagining a plot that has the index of each observation on the x-axis, and the corresponding responses ...
3
votes
1answer
472 views

What test can I use to prove there is an upward trend in time series of ratios assesment in R?

I have a database where experiments are stored. Each experiment has a flag, which says that it was properly registered. I am trying to show with a statistical test, that there is a trend in time that ...
7
votes
2answers
4k views

Parametric, semiparametric and nonparametric bootstrapping for mixed models

Following grafts are taken from this article . I'm newbie to bootstrap and trying to implement the parametric, semiparametric and nonparametric bootstrapping bootstrapping for linear mixed model with ...
5
votes
1answer
3k views

Difference between CI of ANOVA level coefficients vs t-test CI - which one is “correct”?

How do I get the 95% confidence interval for ANOVA level coefficients? For comparison with a constant value, not multiple comparison (like MMC). I tried to take the coefficient's SE from the model: ...
15
votes
4answers
16k views

How to write a linear model formula with 100 variables in R

Is there an easy way in R to create a linear regression over a model with 100 parameters in R? Let's say we have a vector Y with 10 values and a dataframe X with 10 columns and 100 rows In ...
3
votes
1answer
712 views

Testing for equality of variance in permutations (microarray analysis with bioconductor)

I have measured whole-genome gene expression in two groups of animals, n=6 in each group. My goal is to detect differentially expressed genes - pretty standard analysis. The typical thing to do, and ...
1
vote
1answer
250 views

Mixed text and graphical univariate data summary in R

One standard approach we use when describing our data for a paper is to cut our dependent variable into tertiles and then give mean/SD or median/IQR for each tertile for continuous and ...
0
votes
1answer
481 views

How to interpret linear regression results (2-stage vs. 1 stage)?

Could you please shed some lights about how to interpret linear regresssion results (2-stage vs. 1 stage)? For example, I have the following: ...
5
votes
5answers
5k views

Random forest and new factor levels in test set

I am trying to make predictions using a random forest model in R. However I get errors since some factors have different values in the test set than in the training set. For example, a factor ...
4
votes
1answer
2k views

Time series modeling with high-frequency data

I'm looking for some forecasting advice when dealing with seasonal time series data that has a large number of observations. By "large" I only mean a few thousand --- I'm used to such sizes in Data ...
6
votes
4answers
136 views

Could logistic regression be used to detect large errors in least squares regression?

I have the following linear model: $$w^*=\text{arg min}_w\sum_{i=1}^N \bigg(Y_i-\sum_{j=1}^M X_{i,j}\times w_j\bigg)^2$$ Let $T \in N^*$ and $e_i=|Y_i-\sum_{j=1}^M X_{i,j}\times w_j|$. It's ...
2
votes
2answers
2k views

Spline fitting in R - how to force passing two data points?

I am using "smooth.spline" in R. Here is a snippet from the documentation: http://stat.ethz.ch/R-manual/R-patched/library/stats/html/smooth.spline.html smooth.spline {stats} R Documentation Fit a ...
1
vote
2answers
429 views

Specify number of linear discriminants in R MASS lda function

I have a matrix with 1024 features and 10000 samples with a label vector of three different classes. I use R MASS library lda function to compute the model and get ...
2
votes
1answer
283 views

Dynamically generating regression coefficients and tracking their change over time

I'm running a generalized linear model (quasi-poisson regression) as a cron job in R that trains on data from an SQL query. The SQL query pulls data from the last 30 days. Depending on the sample of ...
12
votes
2answers
2k views

Contingency tables: what tests to do and when?

I'd like to see an extension of this discussion of the age-old chi-sq vs. Fisher's exact test debate, broadening the scope a bit. There are many many tests for interactions in a contingency table, ...
6
votes
2answers
6k views

Support vector regression in R

I am searching tutorial for support vector regression in R. I found this and manual for e1071 package. But there is few explanation how to set parameters, like choose kernels, choose regression, not ...
4
votes
1answer
547 views

Jack-knife with time series models

Introduction I am aiming to forecast the annual growth rates for a number of macroeconomic indicators (denote one by $Y_t$). One of the tasks is to test the forecasting performance of rival time ...
4
votes
1answer
590 views

What is the meaning of operators in regression or anova formulas in R

I was wondering, what is the meaning of operators in anova or regression formulas in R For example "+" aov <- aov(x~time+sample, data=data) -> repeated mesures anova? "*" aov <- ...
1
vote
2answers
525 views

Estimating two break points in a broken stick model with random effects in R

Five months ago, jbowman posted a very useful answer to estimate the break point in a broken stick model with random effects in R. I never use "computing" like ...
-3
votes
1answer
118 views

How to read files (text and excell) into R? [closed]

Heloo, pleas help me How to read files (text and excell) into R ? pleas write full instruction. Thank for help
1
vote
1answer
1k views

Wrong values in Dunnett post-hoc test

I can't get the same results in R as in GraphPad Prism for repeated measures anova. The experiment was a stimulation time course, so I have as DV=response and as factor "time" within groups, also I ...
2
votes
1answer
446 views

How can I minimize this least squares problem with inequality constraints?

I have a least square problem with two different inequality problems. I can not use NNLS because its just solves least square problem with equality and inequality problems or just one inequality ...
2
votes
0answers
121 views

Fitting a complex model of variance-vs-mean for quasi likelihood models? (in R)

I wish to deal with over dispersion of a Poisson model. Negative binomial (glm.nb), and quasi likelihood models (family=quasi in glm) do not offer a flexible enough structure of the variance-vs-mean ...
6
votes
3answers
4k views

Creating auto-correlated random values in R

We are trying to create auto-correlated random values which will be used as timeseries. We have no existing data we refer to and just want to create the vector from scratch. On the one hand we need ...
1
vote
1answer
2k views

Posterior probability using forward backward algorithm in R

For one of my projects I need to find posterior probability of visiting a state S and emitting a symbol. I have built a HMM in R and later I get one observation sequence. But, I am not able to ...
1
vote
1answer
166 views

How to check if a sequence of number is time series or not?

I have following numbers ...
1
vote
2answers
229 views

Assuming my three data series are each $\chi^2(1)$ distributed, are they different from eachother?

I systematically chose rare words from three groups of texts (#1, #2 and #3) (the rare words within each group are different, but some rare words may appear in more than one group). Then, for each ...
0
votes
1answer
716 views

PCA loadings interpretation

Regarding the final output of PCA: Using rotation, I'll get a loading for my 50 components, so the equation would be $pc_1=0.05*a_1+0.02*a_2+\dots+0.04*a_{50}$. Now, can I ...
2
votes
2answers
693 views

How to run survival analysis on big dataset?

I am recently involved in a project that needs to analyze the survival time of objects. Therefore, I plan to use the rms package to build a Cox model. The problem is, since the dataset I have is so ...
3
votes
1answer
1k views

Cubic clustering criterion in R [closed]

Does anybody know if any package calculates the cubic clustering criterion (CCC) index in R to aid the selection of optimal number of clusters?
4
votes
2answers
1k views

How to perform a non-equi-spaced histogram in R?

From the R docs for hist: R's default with equi-spaced breaks (also the default) is to plot the counts in the cells defined by breaks. Thus the height of a rectangle is proportional to the ...
5
votes
2answers
2k views

Simulating a Gaussian (Ornstein Uhlenbeck) process with an exponentially decaying covariance function

I'm trying to generate many draws (i.e., realizations) of a Gaussian process $e_i(t)$, $1\leq t \leq T$ with mean 0 and covariance function $\gamma(s,t)=\exp(-|t-s|)$. Is there an efficient way ...
11
votes
1answer
15k views

Plotting confidence intervals for the predicted probabilities from a logistic regression

R and Statistics newbie here. Ok, I have a logistic regression and have used the predict function to develop a probability curve based on my estimates. ...
3
votes
1answer
1k views

Plotting overlaid ROC curves

I'm trying to make overlaid ROC curves to represent successive improvements in model performance when particular predictors are added one at a time to the model. I want one ROC curve for each of about ...
-2
votes
1answer
98 views

How do I make power computation for testing differnce between two log normal means with R? [closed]

I want to do power computation for testing differnce between two log normal means with R. Can you write using R code? best wishes...
3
votes
1answer
497 views

How important is it to define the nested design in a within subject ANOVA?

I am asking to find out why a factor may become non significant after I define the nested design. The following are the two aov analysis in R. Obs (subject #) is the within subject factor and stim3 ...