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 program in `R`.

learn more… | top users | synonyms

0
votes
0answers
14 views

Conditional calculating the numbers of values in column with R [migrated]

have two vectors: x <- c(1,1,1,1,1, 2,2,2,3,3, 3,3,3,4,4, 5,5,5,5,5 ) y <- c(2,2,1,3,2, 1,4,2,2,NA, 3,3,3,4,NA, 1,4,4,2,NA) Here ...
0
votes
0answers
9 views

SSCP in analysis of covariance

I want to use analysis of covariance in R. The model is $y_{ij} = \mu + t_i + r_j + b(x_{ij} - \bar{x}) + e_{ij} $ In R it is possible to get Ryy, Tyy, Eyy, SSE as well as b and adjusted treatment ...
0
votes
1answer
35 views

using cluster information in multiple imputation

i need to impute a dataset all categorical variables before doing analysis. I can just simply impute with mode of all data or a variable. I belief that better option will be to classify the subjects ...
3
votes
1answer
29 views

Getting the equation from R's lm when using a product

Similar to this question: How to translate the results from lm() to an equation? in which the top voted answer said how to get the form of an equation from ...
3
votes
2answers
91 views

Grouping sequential values in R

I have a list of numbers I need to group by similarity (differences being 1 between each). For example, in a list of [198, 202, 207, 218, 219, 220], 190 would be put into a list, 202 would be put into ...
3
votes
1answer
27 views

How to plot correlation coefficients from multiple regressions while leaving out some of the variables from the plot?

Lets say that I have "y" that I want to model with linear regression. "x" and "z" are the things I'm interrested in showing folks, but I also have things that I want to adjust for, but not really show ...
0
votes
0answers
17 views

building a decision tree after association rules

I built association rules using R Arules package. Then I filtered those rules and kept rules that have a specific variable on RHS. That variable is my Y variable. In entire dataset, my variable occurs ...
0
votes
0answers
10 views

What are, in the r function glm, the families “quasi” and “inverse”? [migrated]

The glm function in R takes a "family" argument, which can also be set to "quasi" or "inverse". I couldn't find anything in the docs...
0
votes
1answer
38 views

What is the z-value of glm model parameters?

I know what the z-value of a single observation is, that is explained in Wikipedia. But what is the z-value of a parameter in a glm model?
1
vote
0answers
16 views

error structure in Generalized linear models when y is continuous data and errors not normally distributed

Lets say I have continuous y and x variable and I run a linear regression: mdl1<-lm(y ~ x) A generalised linear model should also give me the same parameters ...
0
votes
0answers
44 views

(Spatial) distance between cluster means

I'd like to cluster points based on a distance criteria. As I want to cluster spatial points I am using euclidean distance and a hierachical cluster approach. In a final step I'd like to cut the ...
0
votes
0answers
9 views

Obtaining Cohen's d from z-test statistic

After an ANOVA, I run post-hoc tests with the glht function in the multcomp package. glht ...
0
votes
1answer
35 views

Repeated-measures, crossover analysis using linear mixed model in R

I have a data set that I am attempting to analyse in R and I am relatively new to the environment. My full data set contains 7 subjects (represented by Subject), that all receive 3 treatments ...
0
votes
1answer
37 views

Calculating hypergeometric probability with approximations

I'm essentially trying to reproduce the dhyper function in R using !n ~ gamma(n+1). Why does this approach not work for large ...
1
vote
1answer
67 views

Analysis of Customer satisfaction surveys

I have customer feedback data about 2-3 products from 100 customers. Number of questions are around 160. I have data in excel format. Header row contains the question and row below contains the ...
1
vote
0answers
27 views

Odds ratios from logistic regression on subsets of data using R

I have 15 subjects each with 200 trials & I'd like to run separate regressions for each subject. If I just run the regression on the whole dataset I am able to generate odds ratios / confidence ...
1
vote
0answers
22 views

fitting an exponential decay onto a regression line

I have data for adherence to medicines which follows a downward linear trend for about 6 months (from 100%) and then plateaus at about 50%. Another way of describing it is by saying that adherence ...
1
vote
0answers
16 views

How to obtain estimates for all levels in a mixed effects model that uses effect (deviation) coding?

I am running a binomial mixed effects logistic regression in R using glmer for a sociolinguistics project. I was asked to used deviation (effect) coding. From what ...
0
votes
0answers
8 views

custom axis labels plotting a forecast in R [migrated]

I'm trying to get some sensible labels on a forecast. Here's my code: ...
0
votes
1answer
20 views

testing for mediation of interactions

I am somewhat familiar with various ways of testing mediation for factors in different types of regression analysis. (I'm using R and currently working with a multilevel binary logistic regression.) ...
2
votes
1answer
37 views

Jeffries Matusita distance for 14 variables

I wish to perform Jeffries-Matusita distance on 14 spectral bands. Is there anyone who can help with how it is done in R? Thank you.
0
votes
3answers
117 views

using random forest for missing data imputation in categorical variables ( in R)

I have following type of associated data. The following example step to generate associated variable. p number of variables and n is number of observations. ...
1
vote
1answer
43 views

Survival analysis in R with left-truncated data

I am doing a survival analysis in R with the survival package. I think I am working with left-truncated data, but I'm not entirely sure how to handle it. I have a ...
1
vote
0answers
35 views

difference in results of mixed effects model in nlme and lmer4 package

Can anyone please tell me why the results of random slope model is different for the same dataset when I use lme and lmer. I first fitted a random intercept model as follows using both lme as well ...
2
votes
1answer
47 views

Exact logistic regression, R, and elrm: data formatting and output

I use SPSS, but am forced to use R for exact logistic regression. So I'm brand new to R (and hating it so far) and also new to logistic regression. I've read the original elrm paper and looked at ...
0
votes
0answers
49 views

Predicting conditional expected lifetime by Cox model in R

I'm using a Cox proportional hazards model, estimate the hazard rate for Levamisole relative to 5-FU, adjusting for Age and Sex. ...
2
votes
3answers
26 views

Kolmogorov-Smirnov of two heart rate samples

I'm accumulating a lot of vital signs from emergency department patients, and would like to assess if different features yield significantly different distributions. Eg. for heart rate I have 888.424 ...
1
vote
0answers
7 views

How to use Levene's test on a data frame in R [migrated]

Say I have a data frame with two columns, height (in inches) and sex (Male or Female) and I want to run levene's test to see if the variance is the same for Male and Female height. How would I do ...
7
votes
1answer
136 views

Combining data from different sources

I want to combine data from different sources. Let's say I want to estimate a chemical property (e.g. a partitioning coefficient): I have some empirical data, varying due to measurement error around ...
2
votes
0answers
44 views

How can I make 2-way ANOVA (Type I, II and III) with R?

I have the following data with factor 1 (A, B and C) and factor 2 (D and E): $$ \begin{array}{ccc} \hline & D & E\\ \hline A & 68 & 59\\ & 65 & 57\\ & 63 & 54\\ ...
0
votes
1answer
33 views

randomSurvivalForest in R

I'm using the randomSurvivalForest package for R, version 3.6.4. I have been using it for a project for a while, with no problem. However, now I have added some additional predictors to my dataset, ...
4
votes
2answers
179 views

cubic relationship after linear relationship

Sorry for my title, but I really don't know how to describe this question. I am fitting a linear regression in R now, and I find that there is one parameter showing linear relationship before certain ...
0
votes
0answers
9 views

Highlight significant coefficients in coefplot [migrated]

Is there a way of changing the colour, to red say, of only significant coefficients on the coefplot plot? For example (plot 2 in coefplot's helpfile), ...
3
votes
1answer
35 views

Fit nonlinear parameter

I'm attempting to fit this model: $P = C_0 + C_1*U^r$ Given known vectors of observations $P$ and $U$, I want to fit values for $C_0$, $C_1$ and $r$. How do I make this fit in R? or preferably GSL ...
0
votes
0answers
13 views

Printing all glm coefficients in R [migrated]

How do I print glm coefficients for all factor levels, including reference level? summary(glm_obj) prints only the values that deviate from reference values. I know that those are 0's, but I need ...
0
votes
0answers
20 views

Predict feature combination with highest probability

I trained a Support Vector Machine with the caret package in R. My dataset looks the following: ...
1
vote
0answers
14 views

How to fit two or more datasets with different occurence for regression

I want to run a regression in R with different datasets. The question is whether stock performance (daily log return) is influenced by factors like interest rates (the one set by fed or ECB), size of ...
0
votes
0answers
9 views

Importing csv file: factors instead of numbers. Retrieving a string vector from a list [migrated]

i) I was importing as csv file of numbers, which is now available as a list L. From applying sapply(L, class) I know that my numbers are now factors. Why is ...
0
votes
0answers
14 views

Feature selection from wavelet transformation in R

I am new to wavelets. Currently, I am developing a prediction model using time series data. I am using the wavelets package in R. I am taking part of the time ...
1
vote
2answers
51 views

R: How to to simulate ARIMA using starting values?

I have built an ARIMA(p,d,q) model, m using say, m <- Arima(ts.data, c(p,d,q)) Given some starting values, I want to simulate future values based on the ...
0
votes
0answers
24 views

differences between different notations in mixed effects model

I have never been so confused in my life. Could anyone please tell me what is the difference between the following mixed effects models: ...
0
votes
0answers
32 views

collinearity in linear mixed effects model

I have one dependent variable (continuous data) and 4 independent data (mix of continuous and count) collected over 35 years across several states. I am using a linear mixed effect models with a ...
0
votes
1answer
59 views

Linear mixed effect models with two independent variables

I am estimating a random intercept and a random slope model using the following R code. My dependent and independent variable are both continuous. ...
2
votes
0answers
38 views

How to use a parametric statistical test with R?

I would like to test the null hypothesis that all coefficients of my categorical variable with 4 Levels are really zero using Wald test & R. I'm new to the R family. And just have some problems to ...
1
vote
1answer
47 views

Non linear regression in R Exponential curve fitting [on hold]

I am trying to fit an exponential model to some data. The data is: ...
1
vote
0answers
33 views

R-squared for linear mixed effects model [duplicate]

I ran linear mixed effects model in R. model<-lmer(yld ~ rain + (1+rain|state),data=data,REML=FALSE) Is there any way I can generate an R-squared for the ...
2
votes
1answer
48 views

Plotting a “ragged array” - a list of vectors in R [closed]

I have a list of numeric vectors, not necessarily all the same length. I'd like to get a plot where each vector in the list is plotted vertically above a label for that vector on the x-axis. Is ...
0
votes
0answers
11 views

How can I estimate a weighted linear regression with fixed effects and many groups in R?

I have a data set derived from administrative registers covering the population of a small European country, containing a large number of defined groups (15 000+). For each of these groups I have ...
1
vote
2answers
184 views

Estimate ARMA coefficients through ACF and PACF inspection

I know that this is probably a question that's been asked plenty of times, but i haven't seen an answer that's both accurate and simple. How do you estimate the appropriate forecast model for a time ...
1
vote
0answers
8 views

determing states in HMM with BIC

I'm fitting a HMM to time series, for each data set I use BIC results to select the optimum number of states. In that, the BIC number is lowest and thereby indicating this model with that number of ...