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

0
votes
0answers
22 views

AUC of Survival ROC smaller than 0.5

If we obtain an AUC < 0.5 analysing a binary response variable (0/1) with a marker, this means the negative values of marker is associated to the value 1 of the response. We could use the trick to ...
2
votes
1answer
35 views

“One sided” classifier

Below was tried in R, but any general solution would be highly appreciated: I have 2 class samples (both classes are balanced). I want to create a classifier, where I only care about 1 class (So, if ...
0
votes
0answers
26 views

Simulation of logistic regression power analysis - output given

This question is in response to an answer given by @gung in regards to this question I am also wanting to use simulation to conduct a power analysis on a multiple logistic regression. To keep it ...
1
vote
1answer
43 views

How do I implement missing value patterns?

I have a training data set and I was able to find some interesting patterns in the missing values, and I used binary variables in order to represent the missingness. I am going to train a model, say a ...
0
votes
0answers
9 views

mu.spline on grofit R package are too small

I'm trying to generate growth rates for 20 different strains of E. coli. I am utilizing the 'grofit' package from R and the program is coming up with nice curves and splines, however, the mu.spline ...
0
votes
0answers
39 views

What does the P value in restricted cubic spline plot mean? [duplicate]

What does the P value in the following example mean? ...
4
votes
2answers
70 views

How to simulate a random slope model

I would like do create a mixed linear model for an unbalanced dataset (different number of events per subject and a few missing values for some time points). I am using ...
0
votes
0answers
11 views

Quickest distance computation between two large vectors in R [migrated]

I wish to calculate the distance between each element in one vector and each element in another vector in the quickest possible way in R. A small example is: ...
0
votes
0answers
16 views

Tree not predicting all factors

I'm using the "tree" function to fit a model to predict a factor "Output" based on A, B, C, D and E ...
0
votes
1answer
26 views

Simulating a Brownian Excursion Process using Software

I would like to simulate a Brownian excursion process using a computer. I want to create sample paths of a Brownian excursion (a Brownian excursion is a Brownian bridge conditioned to be positive at ...
0
votes
1answer
30 views

In a random forest, is larger %IncMSE better or worse?

Once I have built a (regression) random forest model in R, the call rf$importance provides me with two measures for each predictor variable, ...
0
votes
2answers
47 views

R: Multinomial Logistic Regression for health data

I am doing some data analysis on a fairly large health data set of patients with diagnoses and the respective procedures received for each event. I was asked to run a multinomial logistic regression ...
1
vote
0answers
25 views

too many ties in knn? how to solve this problem

I use the knn model to train my data and then eliminate accuracy via cross-validation, but when i use the following code, I get the error: Error in knn3Train(train = c(1680, 300, 480, 240, ...
-1
votes
0answers
27 views

Automatic identification of numeric vs categorical variable

I am trying to build an automatic data preparation pipeline. One of the capability which I want to include is the ability to tag a variable as Numerical or categorical. Currently the idea I have is to ...
1
vote
2answers
71 views

Random Forest - Numeric and Dummy Variables together

I am trying to create a logistic regression model and a random forest model on the same data to predict probability of default. For the logistic regression model, I have created some dummy variables ...
1
vote
0answers
16 views

a crossover repeated measure feed trial using R

I attempt to analyse a crossover feed trial using R but I`m not good at statistical analysis. My data contains 10 subjects, equally divided into 2 groups named A and B. Each group were fed with diet A ...
0
votes
0answers
32 views

At what level are GAM p values significant?

I have constructed a Generalized Additive Model using the mgcv package in R. What I have in the output is the p value of the smoothing functions, as well as the influence of the factor and the ...
0
votes
3answers
49 views

Relationship between price and quantity in R

I tried to figure out how I can analyze this project. To find out how to analyze relationships between prices and quantities. I think with only two variables you can't build models. For example, one ...
0
votes
2answers
70 views

How to fit a glm with sum to zero constraints in R (no reference level)

Question has been rewritten I am trying to fit a glm to find out how the rate of events happens (counts/exposure) related to some covariates, with Poisson error. Counts is the number of events ...
0
votes
0answers
19 views

Difference between weights and prior in rpart and how to use them

I have a question about the "weights" and "prior" in R's rpart function. This question has been asked before here, but the answer doesn't quite make sense. Currently I have very unbalanced data ...
0
votes
1answer
18 views

Multilevel analysis or separate analysis for each level - group / individual analysis

I collected muscle activity levels from 4 different leg muscles on each lower limb over a 20 jump test in 2 groups of athletes. One group has ACL injury (n=11) and there is a control group (n=11). ...
1
vote
0answers
21 views

What is the R code for a 2 one-sided equivalence log-rank test? [closed]

I am trying to perform an equivalence test (alpha = 0.1, beta = 0.8, equivalence interval = 0.85-1.25) for two samples of survival data. Is there a code in R in the Survival package or any other ...
1
vote
2answers
87 views

What measure of training error to report for Random Forests?

I'm currently fitting random forests for a classification problem using the randomForest package in R, and am unsure about how to report training error for these ...
1
vote
0answers
33 views

Problem in passing parameter 'maximize´ through to xgbTree from caret train function [closed]

I am using train in caret package to train a xgbTree model. I want to use the early.stop.round parameter of ...
2
votes
0answers
13 views

Does R's NLS always fail if model parameters are not identifiable?

This question from several years back describes the "singular gradient matrix at initial parameter estimates" error. The answers say the reason for the error is that the parameters in the model are ...
0
votes
0answers
14 views

MARS Model Validation

Can anyone please explain how to validate MARS Model in R. I am running MARS Model with categorical DV and IDV's. And also please explain how to validate the outcome results. Thanks
0
votes
0answers
15 views

is there any R package for calculating transition probabilities for multi order markov chain?

I need to estimate the transition probabilities of a user whose k recent selections were x1, . . . ,xk and will select the item x' next. I know to calculate first order transition probabilities but ...
1
vote
0answers
19 views

Reverse function to tolerance interval, using R

Given a data set and a min/max range, I want to know (with given alpha value) what portion of the population will be in it. This is the opposite of the tolerance interval, as I see it.
0
votes
1answer
45 views

Class weights in caret

I'm using the R package caret to generate classifiers using a variety of different models on an imbalanced dataset. To overcome the class imbalance problem, I am using the "weights" parameter in the ...
1
vote
1answer
58 views

Differences in nlme output when introducing interactions

I am searching for correlations between a dependent variable and a factor or a combination of factors in a repeated measure design. So I used lme() function in R. However, I am getting very different ...
1
vote
0answers
13 views

Interpolating population data

I'm currently doing an internship where I have to calculate incidence ratios for townships for a period of 11 years. I don't have access to the population data for all years and I would like to do ...
0
votes
0answers
30 views

Representing experimental data by unconstrained ordination: PCA, PCoA, or NMDS?

I have a dataset composed by presence of different bacterial families in function at different pesticide treatment. I need to find a good representation of my data but I don't know which method ...
3
votes
1answer
74 views

How to specify logistic regression as transformed linear regression?

I am trying to reproduce the following example of logistic regression with a transformed linear regression: ...
0
votes
0answers
28 views

Sample size for logistic regression with a random effect

I wish to dig out a sample size (or to do a power analysis for a given sample size) for a logistic regression model with a random effect. To simplify, let's say I have a binary dependent variable Y ...
1
vote
1answer
37 views

Estimating regression coefficients in the presence of stochastic trend

I have a very basic problem. My time series is modeled as: $$Y_t = a_t + \beta x_t + v_t$$ $$a(t) = a(t-1) + w_t $$ where $ w_t$ ~ $N(0,W) $ with known W, and $v$ is white noise. I don't know if ...
2
votes
1answer
98 views

What does the HAT matrix looks like when the residual sum of square equals zero?

What does the HAT matrix looks like when the residual sum of square equals zero? How do the predicted y and the measured y relate to each other in this case?
3
votes
1answer
97 views

Multiple ARIMA models fit data well. How to determine order? Correct approach?

I've got two time series (parameters of a model for males and females) and aim to identify an appropriate ARIMA model in order to make forecasts. My time series looks like: The plot and the ACF ...
0
votes
0answers
10 views

Canonical correlation analysis on R: repeated data

I'm new to this, so I am sorry if it a dumb question! I have one set of data with 88 variables (X) and another set of data with 3381 variables (Y), hence I will be using the regularised CCA (both ...
1
vote
0answers
36 views

R optim function : can it be used as a Solver [migrated]

I saw another question here on this forum, and saw that the Optim function was used as a kind of Solver instead of as an optimizer. Here is the link: ...
0
votes
2answers
26 views

Strange result in Poisson regression - R

I have performed a Poisson Regression in R, but I got strange results that I cannot find an answer for. My data is like this: ...
0
votes
0answers
9 views

softmax in nnet with cost function

I have 40 classes in a classification problem. I'm using nnet with softmax but since the classes are very imbalanced I get the same probabilities for every case to predict. I read about F1 score. Is ...
1
vote
1answer
36 views

CLT simulation with R

I am trying to run a simple CLT simulation with R. I want to create a vector with 10000 dice rolls, then take 100 means of samples of "n" size to see how when "n" increases, the distribution starts ...
2
votes
0answers
31 views

Modelling against “day” or “day^2” in to look at change over time?

I'm a masters student trying to model changes in behaviour, heart rate variation and faecal cortisol as welfare measures in sheep over the course of 22 days. Days -4 to -1 is used as baseline, day 0 ...
0
votes
0answers
2 views

open new seperate R session from R script for several processes [migrated]

Does anyone know if its possible to source R scripts from within a main R script buy have each sourced file run in a separate R session? I am trying to run multiple R processes in parallel (without ...
0
votes
0answers
6 views

Test for Regression Slope different from zero in R [duplicate]

I know how to do the Test for Regression Slope in R when the H0: b1=0 H1: otherwise but how do I do the Test for Regression Slope when i want to check H0: b1=1 H1: otherwise is it possible? ...
0
votes
1answer
34 views

Statistical test for logical vectors in R

The first issue that I feel like I have is that I have limited experience with actually using statistical tests. I apologize ahead of time if this question is illogical. I have two example vectors ...
0
votes
0answers
8 views

Input, analyse and graph Semantic Differential Data with R?

Has anyone tried to use Semantic Differential data in R? This is a very useful survey scale and I was surprised that information on it's use in R is very hard to find. The Likert package states ...
1
vote
0answers
74 views

Mixed effects model for longitudinal data

I have the following data: a group of patients for which I measure blood pressure (bp) 1 hour before treatment where they are given a placebo, then during treatment with the drug, and then 1 hour ...
0
votes
0answers
34 views

Multiple comparisons in linear mixed models for several correlations, in R

I am performing several correlations in R using the lme function, on a data set corresponding to the result of an experiment involving repeated measures. I would like to know whether some kind of test ...
0
votes
0answers
17 views

Question about aggregate function [migrated]

I'm an R user and I'm trying to rewrite some second hand SPSS code in R. Could someone give me a basic idea of what this code is achieving?: ...