Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [r]

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`.

0
votes
0answers
4 views

R program - Impute missing values based on values from other column

I have the below dataframe with missing values (Purchase column) I want to know how to impute the values based on the Item column. Example; In the first row, O has the price of 190. However, the ...
0
votes
1answer
9 views

Segmented regression

I am working with data consisting of observations over time (abundance and harvest of different game species over several years). I am interested in finding if and when the direction is changed (i.e. ...
0
votes
1answer
30 views

Degrees of freedom in a linear mixed model (or ANOVA) - Categorical factors versus continuous numbers

I have data from 20 individuals. In general, each individual has measurements (i.e., called Value below) from the Left and Right arm taken at different months in ...
0
votes
0answers
3 views

Nipals and prcomp differences and data size relationship [on hold]

I'm pretty new in R and data analysis and I found a strange behaviour which I wanted to discuss with you. I had a 486 observation of 5000+ variables and I want to cluster them with Mclust. Each value ...
1
vote
0answers
30 views

Fitting a multiple linear regression in R [on hold]

I have annual mean temperature and precipitation data from 1901 to 2015: I want to do a multiple linear regression: ...
0
votes
0answers
10 views

using anova to compare two linear models of unequal sample size: error [migrated]

Here is an example of what I want to do, with a randomly generated number set: a<-runif(100, min =0.5, max=1); b<-runif(100, min = 0, max =1); c<-factor(rep(c("High", "Low", "High", "High")...
-1
votes
1answer
38 views

Is Maximum Likelihood Estimation the median? [on hold]

I asked what maximum likelihood estimation to a friend of mine. He told me that it is the median which I don't understand.
0
votes
0answers
16 views

Determining the probability of imbalance using histogram in clinical trial [on hold]

I have 10000 simulation of 64 units using simple randomization with two treatment A and B. I have then plotted histogram using the number of patient who received treatment A. How can I determine the ...
1
vote
0answers
7 views

R - Deriving short and long run effects in ARDL model

I have an ARDL Unrestricted ECM that passes the Bounds test for cointegrtion. Now I want to calculate the short and long run estimates of the model, however I am unsure of how to do this in a ...
0
votes
0answers
9 views

Calculate correlation between different variables group by Name with some NA:s

I have to calculate the correlation between a couple of variables grouped by name. I have to do this quite often so I want to write a function for it. So, I have a couple of variable, lets call them ...
-1
votes
0answers
26 views

Maths behind `geom_line()` in R [on hold]

I'm looking to fit a curve that ideally looks like a sigmoid curve. I can do this and get the sigmoid with geom_line(). However, I would like to know the ...
0
votes
0answers
20 views

How to merge few types of variables to one explanatory variable

so I have a data set of bike rentals in Washington D.C. Some of my variables are factors and some are numerics and continuous. I uploaded an image of a sample of my dataset so it will be easier for ...
0
votes
1answer
23 views

How is probability y = j|X calculated from an ordinal logistic regression model?

I have an ordinal logistic regression model fitted with lrm from the rms library in R, and am presenting results as prob y = j|X ...
1
vote
1answer
15 views

Vectorised computation of logsumexp

In this related post there is an explanation of how you can add together two very small probabilities using the logsumexp function, and how this can be programmed into base ...
0
votes
0answers
28 views

Random Regression in R

I am a student. I have some knowledge of mixed regression models. I would like to implement Random Regression in R. I found "Random Regression Models" by Schaeffer (http://animalbiosciences.uoguelph....
0
votes
0answers
13 views

Feature selection and weighting [on hold]

I need to do feature selection and feature weighting for data is related to race competition that the group of data in each race are related to each other in comparison with the whole data set, I mean ...
0
votes
0answers
23 views

When calculating sum of observation in Bayes Theorem, why do we remove one outcome?

relatively quick question regarding this course question: Hearing about your brilliant success in working with M&Ms, Mars Inc. transfers you over to the Skittles department. They recently have ...
0
votes
1answer
19 views

Performing repeated measures ANOVA on unstacked data in R

I am trying to do a repeated measures ANOVA on unstacked data for my experiment. For background, my experimental design is as follows: I have 160 stimuli divided evenly into 8 counterbalanced list, ...
0
votes
0answers
22 views

What causes the degeneration of correlation in a simulated time series?

I am trying to simulate an ARMA(1,1) process with the following characteristics: $\phi$ = 0.97 $\theta$ = 0.80 Standard deviation $s$ = 245 Mean $m$ = 1000 ...
5
votes
2answers
67 views

Whether to use factors in R and when ordered factors?

I've done some searching on StackExchange and become more and more confused about using factors and ordered factors in R modeling. I've encountered several circumstances: A variable is characters ...
1
vote
3answers
43 views

Meaning of chi-squared in R Kruskal-Wallis test

I have a simple question to ask, I think it was not covered in other questions. I am running a Kruskal-Wallis test in R, using the function kruskal.test. The output gives me the p-value and a chi-...
0
votes
0answers
7 views

summary.rq output depends on sample size [migrated]

I found out (see below) that the function summary.rq (page 88) from the quantreg package prints different output, depending on whether sample size is greater equal or less than 1001. I am aware, that ...
1
vote
0answers
13 views

Multivariate $t$ ('mvt') - adjustment in emmeans in R

I am doing post-hoc comparisons of contrasts based on linear mixed models I built in R. I am using the emmeans package for the comparisons. One of the default ...
0
votes
0answers
37 views

Is there any statistical test for the difference between two percentiles?

I know the R function t.test to perform the statistical test for the difference bewteen two means, is there any test for the difference between, say, the 95th ...
0
votes
0answers
15 views

GLM Gamma family in ggplot: Difference between geom_line() and stat_smooth() in curve representation [on hold]

I've like to plot a glm model with Gamma family in ggplot. My ideia is use stat_smooth() for confidence interval representaion of my ajusted model. The curve of geom_line() with preticted points is ...
0
votes
1answer
40 views

R code glmer: Different results with same data

I'm trying to run a mixed model analysis and so far I've found two ways to write a negative binomial distribution model for my data: ...
0
votes
0answers
22 views

Excel chisq.test equivalent in R language [on hold]

My statistical knowledge is very limited, so please have mercy. My problem is relatively simple (but I know deep down it is not, so I tried to keep it simple). I have the following data in Excel: ...
0
votes
0answers
19 views

Analyzing change over time in population - what test?

I have a very large dataset that has 3 variables I'm interested in: year, place, and observation. Every year, at the same time per year, people go out and survey different areas for fruits. They then ...
1
vote
0answers
11 views

r - Poor model fit with StMoMo package on Human Mortality Database

I am fitting USA mortality data from Human Mortality Database (with data downloaded from here after registering for a free account https://www.mortality.org/cgi-bin/hmd/hmd_download.php) with the ...
1
vote
0answers
25 views

Data perturbation with normal variables

I am doing some projects related to statistics simulation using R based on "Introduction to Scientific Programming and Simulation Using R". In the Students projects session (chapter 24), I am doing ...
0
votes
0answers
9 views

Decomposition Difference Between Twitter and STL Method

I am having a lot of trouble understanding the difference between the two decomposition methods: twitter and stl. https://www.rdocumentation.org/packages/anomalize/versions/0.1.1/topics/...
0
votes
0answers
21 views

Grouped and ungrouped binary data: different results in R and Stata

I am working with grouped binary data in order to reduce my data from many individual observations (2.2m) to far fewer covariate patterns (approx 12.5k). Doing so should produce the same results in a ...
0
votes
0answers
5 views

Training model with large range for target variable [on hold]

I am training a model using R and have a specific issue with a target variable whose values vary from 10n to 10m (6 orders of magnitude). I took a log transform before training the model and the error ...
0
votes
0answers
10 views

Anomalize Package time_decompose

I am trying to figure out what the meaning is behind each of the different compositions of the time_decompose function in the ...
1
vote
1answer
24 views

lmer multilevel regression with intercept constraint [on hold]

I regularly have this problem: I want to fit a multilevel regression, with constraint. I don't know how to do that. I usualy end up using lavaan, as it allows to ...
1
vote
0answers
21 views

Creating sample data set of quiz with n number of questions and set number of students using R

I am very new to R and statistics. What I am trying to do is create some sample data sets of quizzes with n number of questions that the x number of students get correct. Using this, I would like to ...
0
votes
0answers
24 views

T test calculation for µ AR model

if I have to test if the mean of this is AR is equal to 0, how do I proceed? phi0/(1-phi1-phi2-phi3) and then t-test or phi/SE(phi0) Thanks
1
vote
1answer
31 views

Linear regression - Can I log transform dependent variable and one of the independent ones and keep the rest not transformed? [duplicate]

I have model where my dependent variable is Total money spend and then I have independent variable Income and some other ...
0
votes
0answers
24 views

glmer in R, complex random effect

I'm trying to run a mixed model analysis with a negative binomial distribution. Here is the code and the result: ...
0
votes
0answers
10 views

Retrieve the features used in SVM, (ksvm)

I have used ksvm to train a model, however I don't have a clue on how to the get the contributing features that were selected/used. The following code was used: <...
1
vote
1answer
21 views

Does R's arima() fit / use multiplicative or additive seasonality?

I have searched Cross Validated and read the documentation of the stats package in R, but I cannot figure out, whether the arima() implementation uses additive or ...
0
votes
0answers
33 views

Bootcov in R’s rms package not working when cluster variable included in regression model as fixed effect

I'm trying to use bootcov in Frank Harrell’s rms package in R to get standard errors that account for state-level clustering (...
2
votes
0answers
31 views

Obtaining Standard Errors in Optim() in R [duplicate]

I'm using a maximum likelihood estimation and I'm using the optim() function in R in a similar way as follows: ...
1
vote
0answers
15 views

What are some good alternatives to a network diagram for data visualization? (preferably in R)

I'm working on a scoping review project that involves understanding how often different behavioral constructs (motivation, engagement, etc, based on standardized tests) are related to therapeutic ...
1
vote
1answer
43 views

R - lme4 - Help on repeat measures over time, continuous predictor interactions

I've created an exmaple data set below to hopefully help answer a question in regards to a lme4 in R and measurements over time. The data is 4 plots, measured over 4 years, with the dependent ...
0
votes
0answers
24 views

Warnings using glmer() in R

I'm trying to analyze the differences in the number of plant species found in different types of fields. The number of species per sample is a non-integer because I had to adjust the number to account ...
2
votes
0answers
45 views
+50

How can I estimate the highest posterior density interval from a set of x,y values describing the PDF?

I'd like to estimate the Highest Posterior Density Interval (HPDI) of a calculated density function, rather than from empirical samples as is normally done (e.g., from an ...
1
vote
0answers
22 views

Regression with a high number of 0's for target variable. How do I approach this?

I have a dataset where the probability of an event happening is very low (15%-20%). When the event happens, there's a dollar amount attached to it. The distribution is very right skewed, ranging from -...
0
votes
1answer
22 views

Time series analysis via generalized additive models: model assumptions and stationarity

I have settled on building a generalized additive mixed model using mgcv::gamm, on data and for purposes I have described in more detail here. In a nutshell, I want ...