similar to: apply

Displaying 20 results from an estimated 20000 matches similar to: "apply"

2024 Oct 04
3
apply
Homework questions are not answered on this list. Best, Uwe Ligges On 04.10.2024 10:32, Steven Yen wrote: > The following line calculates standard deviations of a column vector: > > se<-apply(dd,1,sd) > > How can I calculate the covariance matrix using apply? Thanks. > > ______________________________________________ > R-help at r-project.org mailing list -- To
2024 Oct 04
3
apply
OK. Thanks to all. Suppose I have two vectors, x and y. Is there a way to do the covariance matrix with ?apply?. The matrix I need really contains the deviation products divided by the degrees of freedom (n-1). That is, the elements (1,1), (1,2),...,(1,n) (2,1), (2,2),...., (2,n) .... (n,1),(n,2),...,(n,n). > Hello, > > This doesn't make sense, if you have only one vector you
2024 Oct 04
2
apply
Hello I have a vector: set.seed(123) > n<-3 > x<-rnorm(n); x [1] -0.56047565 -0.23017749 1.55870831 I like to create a matrix with elements containing variances and covariances of x. That is var(x[1]) cov(x[1],x[2]) cov(x[1],x[3]) cov(x[2],x[1]) var(x[2]) cov(x[2],x[3]) cov(x[3],x[1]) cov(x[3],x[2]) var(x[3]) And I like to do it with "apply". Thanks. On 10/4/2024 6:35
2024 Oct 04
1
apply
On 10/4/2024 5:13 PM, Steven Yen wrote: > Pardon me!!! > > What makes you think this is a homework question? You are not > obligated to respond if the question is not intelligent enough for you. > > I did the following: two ways to calculate a covariance matrix but > wonder how I might replicate the results with "apply". I am not too > comfortable with the
2024 Oct 04
1
apply
Pardon me!!! What makes you think this is a homework question? You are not obligated to respond if the question is not intelligent enough for you. I did the following: two ways to calculate a covariance matrix but wonder how I might replicate the results with "apply". I am not too comfortable with the online do of apply. > set.seed(122345671) > n<-3 > x<-rnorm(n); x
2024 Oct 04
1
apply
Even if this is not a homework question, it smells like one. If you read the Posting Guide it warns you that homework is off-topic, so when you impose an arbitrary constraint like "must use specific unrelated function" we feel like you are either cheating or wasting our time, and it is up to you to explain why we should follow you down this rabbit hole, keeping in mind that statistics
2024 Oct 04
1
apply
Hello, If you have a numeric matrix or data.frame, try something like cov(mtcars) Hope this helps, Rui Barradas ?s 10:15 de 04/10/2024, Steven Yen escreveu: > On 10/4/2024 5:13 PM, Steven Yen wrote: > >> Pardon me!!! >> >> What makes you think this is a homework question? You are not >> obligated to respond if the question is not intelligent enough for you.
2024 Oct 04
1
apply
Hello, This doesn't make sense, if you have only one vector you can estimate its variance with var(x) but there is no covariance, the joint variance of two rv's. "co" or joint with what if you have only x? Note that the variance of x[1] or any other vector element is zero, it's only one value therefore it does not vary. A similar reasonong can be applied to cov(x[1],
2024 Oct 04
1
apply
It's still hard to figure out what you want. If you have two vectors you can compute their (2x2) covariance matrix using cov(cbind(x,y)). If you want to compute all pairwise squared differences between elements of x and y you could use outer(x, y, "-")^2. Can you explain a little bit more about (1) the context for your question and (2) why you want/need to use apply() ? On
2024 Oct 04
1
apply
? Fri, 4 Oct 2024 20:28:01 +0800 Steven Yen <styen at ntu.edu.tw> ?????: > Suppose I have two vectors, x and y. Is there a way > to do the covariance matrix with ?apply?. There is no covariance matrix for just two samples (vectors) 'x' and 'y'. You can only get one covariance value for these. If you had a pair of vectors of _random variates_, the situation would be
2024 Oct 04
0
apply
On 04.10.2024 11:13, Steven Yen wrote: > Pardon me!!! > > What makes you think this is a homework question? You are not obligated Otherwise you called cov() Best, Uwe Ligges > to respond if the question is not intelligent enough for you. > > I did the following: two ways to calculate a covariance matrix but > wonder how I might replicate the results with
2024 Jul 12
2
grep
Thanks. In this case below, what is "x"? I tried rownames(out) which did not work. Sorry. Does this sound like homework to you? On 7/12/2024 5:09 PM, Uwe Ligges wrote: > > > On 12.07.2024 10:54, Steven Yen wrote: >> Below is part a regression printout. How can I use "grep" to identify >> rows headed by variables (first column) with a certain label. In
2024 Jul 12
1
grep
Could not get "which" to work, but my grep worked. Thanks. > which(grep("very|somewhat",names(goprobit.p$est))) Error in which(grep("very|somewhat", names(goprobit.p$est))) : argument to 'which' is not logical > grep("very|somewhat",names(goprobit.p$est)) [1] 6 7 8 9 10 11 12 13 28 29 30 31 32 33 34 35 50 51 52 53 54 55 56 57 On 7/12/2024
2011 Nov 15
5
Convert back to lower triangular matrix
Given a vector;> ab = seq(0.5,1, by=0.1)> ab[1] 0.5 0.6 0.7 0.8 0.9 1.0 The euclidean distance between the vector elements is given by the lower triangular matrix > dd1 = dist(ab,"euclidean")> dd1    1   2   3   4   52 0.1                3 0.2 0.1            4 0.3 0.2 0.1        5 0.4 0.3 0.2 0.1    6 0.5 0.4 0.3 0.2 0.1 Convert the lower triangular matrix to a full
2017 Jun 01
2
Problem of a function I wrote
Hello everyone, I have been working on a code which simply repeatedly appends a number into a vector and write a file. However, it could not be properly implemented when I use it. It works when I run it line by line. I wonder what is the problem and I appreciate anyone who is willing to help. The function and the example code is attached. Any advice is appreciated! Best, Yen
2012 Jun 20
1
prcomp: where do sdev values come from?
In the manual page for prcomp(), it says that sdev is "the standard deviations of the principal components (i.e., the square roots of the eigenvalues of the covariance/correlation matrix, though the calculation is actually done with the singular values of the data matrix)." ?However, this is not what I'm finding. ?The values appear to be the standard deviations of a reprojection of
2017 Aug 16
4
{nlme} Question about modeling Level two heteroscedasticity in HLM
Hello dear uesRs, I am working on modeling both level one and level two heteroscedasticity in HLM. In my model, both error variance and variance of random intercept / random slope are affected by some level two variables. I found that nlme is able to model heteroscedasticity. I learned how to use it for level one heteroscedasticity but don't know how to use it to model the level
2024 Jul 12
1
grep
On 12.07.2024 10:54, Steven Yen wrote: > Below is part a regression printout. How can I use "grep" to identify > rows headed by variables (first column) with a certain label. In this > case, I like to find variables containing "somewhath", > "veryh",?"somewhatm", "verym", "somewhatc", "veryc","somewhatl",
2017 Jun 01
0
Problem of a function I wrote
Hello everyone, It seems that I was not successfully attached the code. Here is the code. I appreciate any help! Best, Yen ?? b88207001 at ntu.edu.tw: > Hello everyone, > > I have been working on a code which simply repeatedly appends a > number into a vector and write a file. However, it could not be > properly implemented when I use it. It works when I run it line by
2010 Jun 15
3
Problem about zero
Hello, everyone, There's a problem about zero in R and I really need your help. I have a vector shown as x=c(0.1819711,0.4811463,0.1935151,0.1433675), The sum of this vector is shown as 1 in R, but when I type 1-sum(x), the value is not zero, but -2.220446e-16. I can accept that this value is quite small and could be seen as zero, but there would be a problem when it's not really