Stack Exchange Network

Stack Exchange network consists of 175 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`.

1
vote
0answers
22 views

Zeros in Experiment Analysis

I am analyzing data of an experiment close to the ultimatum game. Participant A makes a decision x or y, and then Participant B can decide whether to punish Participant A. Participant B can choose ...
0
votes
0answers
12 views

Gradient Descent method for Wolfe Duality Hyperplane Optimization

I am troubling myself by learning how to build an optimal hyperplane for a separable case using the $\texttt{iris}$ data in R. The function I am trying to maximize w.r.t $\alpha_{i}$ is: $$ L_D = \...
1
vote
0answers
18 views

LDA Fit using Caret does not give Standard Deviation

I am following the steps outlined in this tutorial. I have followed along and running into an issue at step 5.3. The output of the LDA model gives me all the expected information, except the Accuracy ...
0
votes
0answers
21 views

Interval scale variables in R

This is a question I found surprisingly hard to answer using Google: How is interval scaled data implemented in R? For nominal, its factor(), for ordinal, it's ordered(), and for ratio scale, it's ...
0
votes
0answers
18 views

Why does removing the intercept in my categorical GLM result in the same model?

I'm trying to understand what is going on when I remove the intercept in my model using y ~ x + 0 Why do these models have the same predicted values despite one not having the intercept? ...
0
votes
0answers
10 views

How to perform joint estimation of parameters from two NLS-regressions in R?

First of all, I am new to the board so excuse me if I am not writing this post in the most optimal way. That aside, I am trying to run some models on optimal entry timing for successive product/...
0
votes
0answers
12 views

Using CausalImpact in R, observed data affected by event that could not affect priors

I am just starting out using the Causal Impact package in R. I am looking at observed data where I know there will be periods of extra traffic due to outside forces. However I cant find any unbiased ...
1
vote
2answers
48 views

The non-linear extra sum of squares? What is this?

I encounterd in the article I read the term the non-linear extra sum of sqare with the reference to Bates and Watts 1988. I do ...
0
votes
0answers
19 views

Comparing coefficients of survival analysis with Gompertz distribution in R

I am performing Gompertz analysis of survival to calculate initial mortality rate (IMR) and Gompertz coefficient (rate of ageing) of different strains of worm. I am doing this by using the package ...
0
votes
1answer
35 views

Given a standard regression output table in a publication, how do you compute p-values?

If I'm looking at a paper that reports regression coefficients and the standard errors in parenthesis, I know that I can compute a t-statistic by dividing the coefficient by its SE. However, how can ...
0
votes
0answers
14 views

How do you perform a good Dynamic principal component analysis (DPCA) in R?

I have a spatiotemporal data (time series of 20 variables). I want to reduce its dimension using techniques such as PCA. However, traditional PCA assumes that the observations (in this case, values ...
0
votes
0answers
6 views

How to replicate this function in R many times? [migrated]

I need to replicate the following function many times using different elements. I am very new to R and the only way I know how to is with copy-paste. I need to calculate the proportion that each ...
1
vote
1answer
27 views

Interpret Intercept Plot from Series of Quantile Regressions in R

Essentially, I am looking at a set of housing data from 2000-2017 and I am examining 'affordability' by year through quantile regression. The Y variable (affordability) is a ratio of what an ...
1
vote
0answers
13 views

Analyzing animal occurrence data to detect a movement bias in R

I have occurrence data for animal locations over several months. These UTM coordinates are coupled with a date and time of occurrence, but they differ from tracking data in that it is not over ...
0
votes
0answers
11 views

Eta squared effect size calculation for two-way repeated measures ANOVA

I am trying to use my R output for my two-way repeated measures ANOVA to calculate the eta-squared effect sizes. Can anyone help with the code for this, or alternatively how to do it by hand from the ...
0
votes
0answers
14 views

Transforming GPS location datapoints in R

I'm very new to this kind of analysis so I hope my question is of good interest. I've GPS locations from three independent GPS loggers, which data consists of two variables: latitude and longitude. ...
0
votes
1answer
32 views

Multinomial logistic regression reference category function

Bit of background info on the data and methods that I've used. I have a forest road data that consists of one dependent variable which has 4 classes (0-3). The Dependent variable reflects possibility ...
0
votes
1answer
14 views

How do I specify a lavaan sem model with more than one single-indicator factor?

I am trying to specify a lavaan CFA that has some factors with three or more indicators, one factor with two indicators, and two factors with one indicator. For the single indicator factors, I tried ...
2
votes
2answers
59 views

How can you implement latent class analysis with distal outcomes in R?

I am looking to fit a fairly straightforward latent class analysis (LCA) model to derive phenotypes / clusters of a disease (in R). My dataset contains the manifest variables used to derive the ...
0
votes
0answers
13 views

How to return predicted values to original scale after using diff() then modeling using nnetar() functions

I have a series which is a non-stationary series. I analyzed its stationary using Augmented Dickey–Fuller test. I'd like to make a prediction model using nnetar() function in forecast package for my ...
1
vote
0answers
21 views

Multivariate ordinal regression

I am facing the following problem: 100 respondents answered a questionnaire with 30 questions, each with a 5-point-Likert scale. The 30 questions can be subdivided into 2 x 15 (Blocks A and B). ...
1
vote
0answers
10 views

Average Sample Number using Page's CUSUM procedure?

I am trying reproduce the Table 1 results from the page 12 using the equation given the page 13.To access the journal article please click https://arxiv.org/pdf/math/0605322.pdf. The corresponding ...
0
votes
0answers
22 views

Standard partial regression plot vs. effect plot from 'effects' package

I'll use a modification of this example to ask my question about an apparent alternative way of presenting a partial regression plot, using the effects package. ...
1
vote
2answers
35 views

Inverse Fast Fourier Transform in R

plot(fft(fft(1:100),inverse = "true")/100) plot(1:100) In the above example, I was expecting the plots to be identical. The first, however, returns: while the ...
-1
votes
0answers
15 views

argument is of length zero while a loop [migrated]

i <- 2 j <- 0 for (i in 2:1000) { if(return.prime(i)){j = j + 1} i = i + 1 } I want to check how many prime numbers in 1 to 1000 using my own function ...
0
votes
0answers
13 views

Calculating mean square error for a knn regression object

I'm fairly new to knn, R implementation and am trying to figure out how to calculate the MSE for a model that uses knn based on linear regression with 3 nearest neighbors and get the error shown above....
0
votes
1answer
16 views

Different p value of two different function in R while computing Cramér-von Mises test

When I tried to run Cramér-von Mises for generalized extreme value distribution in R, I got different p value for cvm.test function and gnfit function. The difference is quite significant like 0.07. ...
7
votes
2answers
190 views

Logistic regression BIC: what's the right N?

TL;DR: Which $N$ is correct for BIC in logistic regression, the aggregated binomial or Bernoulli $N$? UPDATES AT BOTTOM Suppose I have a data set to which I'd like to apply logistic regression. For ...
0
votes
0answers
19 views

How to back-transform glmer() cbind() proportion data

I have fit a binomial GLMM (glmer) to a response variable that is a proportion. How my data looks: ...
0
votes
0answers
43 views

Nonparametric for lmer

I am trying to fit a model based on the df dataframe, where I want to be able to compare all of the levels between/within the treatments (...
0
votes
0answers
11 views

Appropriate regression to predict >2 fractions?

Let's say I have demographic data on various classes and the proportion of students in the class who are black, white, etc. I'm trying to create a regression to determine features of the class that ...
0
votes
0answers
7 views

Series of structural time models with correlated residuals [closed]

When I model a time series using structura models and then the residuals still have a correlation structure, what should be done in those cases? It should be modeled by ARMA and, if so, how is it ...
2
votes
2answers
75 views

Interpretation of linear regression interaction term plot

I am interested in looking at the relationship between plant productivity, temperature change and plant biomass change. I have run a linear model in R using the below equation for this with plant ...
0
votes
0answers
19 views

Unbalanced Two Way ANOVA

I am attempting to finish my stats on my Master's thesis and am having difficulties with which statistics test I should be using, and how to go about doing so. I have collected chl-a samples at 15 ...
1
vote
1answer
18 views

Should I report the pseudo $R^2$ value for full or final logistic regression model after removing NA's & running stepwise selection?

I'm working with a logistic regression model in r. model <- glm(response~., family="binomial", data) and I'm using ...
0
votes
0answers
47 views

Expected value of a variable given a probability distribution

I have fitted some data with a normal and gamma distribution. But I need to find the expected value of my variable. For example is x is my data (mine is not normal) and fit them into a normal and ...
0
votes
1answer
20 views

Post hoc test for chi-squared with given (unequal) probabilities

I am conducting a chi-squared test to see whether the categories survey respondents mention match the distribution of categories in the population. This test is significant, but I am wondering how to ...
0
votes
0answers
32 views

Why is this chi-squared test negative?

I ran two models, one restricted and another unrestricted.The log-likelihood value of the unrestricted model is however unexpectedly smaller than the restricted one. Could anyone tell me what the ...
0
votes
1answer
18 views

R: How to use lmer for more than two levels?

I want to fit a model with 5 levels. All levels are hierarchical. That is, level 5 is nested in level 4, level4 is nested in level 3, etc. level 2 is nested in level 1. All levels are factors. Single ...
0
votes
0answers
21 views

Gower Distance and PAM algorithm with Random Forest for Variable Selection

I am currently working with cluster analysis and am trying to create clusters based on the important variables. My data consists of both categorical and continuous variables thus I have used the ...
1
vote
0answers
24 views

Analysis of Variance table (lm function)

I have a dataset dataset take has compnds1 (chemical compounds from 1st harvest), compnds2 (chemical compounds from 2nd harvest), method (=treatments, there are 4 treatments, 1 is control, 2 is hydric ...
1
vote
1answer
39 views

R: GLMM for unbalanced zero-inflated data (glmmTMB)

Study design: I have count data of snails per date, counted over many dates at sites, nested in localities. So, in each locality the snail counts come from several different sites, repeatedly ...
0
votes
0answers
28 views

interpretation of ordered logit regression with categorical independent variate

I would like to predict the quality of plants in certain area. I divided the quality of the plants in 5 groups; 0 to 5. And we've measured 5 different areas; control, 1, 2, 3, and 4. I ran a logit ...
0
votes
2answers
19 views

Test statistical significance with small number - Fisher's exact test

Before the part of the question related to the title, here is some background: I'm build a model that tries to predict a binary outcome ($Y$), given a set of features. Some of this features are ...
0
votes
0answers
24 views

analysis of categorical data for behaviour experiment

I have been stuck on how to analyse my data for many weeks. My dataset consist of 13 variables all of which are categorical. 3 variables details the continent, population and type of treatment of my ...
0
votes
0answers
24 views

Simulation of tossing coins in R

If $X$ = # of heads showing when three coins are tossed, find $P(X=1)$, and $E(X)$. Let $(X=1) = Head$, and $(X=0) = Tail$. Say, I want to solve this problem using ...
1
vote
1answer
21 views

Regression: within and between-subject variable interaction

I have a dataset with the following variables, which are measured between subjects (i.e. 1 measurement per individual): ID: subject identifier ...
2
votes
0answers
26 views

Extracting the linear equation for a circular-circular regression

I am trying to create a predictive model using a relationship found by the lm.circular function from the circular package. The ...
1
vote
1answer
40 views

R Calculate Deviance Residuals in a Logistic Regression [closed]

I am working on a project, where I want to build a function which performs a logistic regression but does not use the glm() function. I ran in a little bit of difficulties, when it comes to calculate ...