[R-pkg-devel] [Error] data length differs from size of matrix

Bill Dunlap w||||@mwdun|@p @end|ng |rom gm@||@com
Fri Jun 4 20:12:47 CEST 2021


solve_svd's second argument is 'tolerance', a small scalar value, not the
right hand side of X %*% beta == Y.  It returns the [approximate] inverse
of X, not beta.

solve_svd(cor.x2,cor.y) should probably be solve_svd(cor.x2)%*%cor.y (or
just solve(cor.x2,cor.y)).

-Bill

On Fri, Jun 4, 2021 at 8:41 AM Bill Dunlap <williamwdunlap using gmail.com> wrote:

> The offending line in path_coeff seems to be
>    betas[i, 2:nvar] <- t(solve_svd(cor.x2, cor.y))
> where i is a single integer, nvar is 15, and the right hand side is a 14
> by 14 matrix.  What is this line trying to do?  Did it ever give the
> correct result?
>
> -Bill
>
>
> On Fri, Jun 4, 2021 at 7:39 AM Bill Dunlap <williamwdunlap using gmail.com>
> wrote:
>
>> That log file includes the line
>>     using R Under development (unstable) (2021-05-30 r80413)
>> and later says
>>
>> The error most likely occurred in:
>>
>> > ### Name: path_coeff
>> > ### Title: Path coefficients with minimal multicollinearity
>> > ### Aliases: path_coeff path_coeff_mat
>> >
>> > ### ** Examples
>> >
>> > ## No test:
>> > library(metan)
>> >
>> > # Using KW as the response variable and all other ones as predictors
>> > pcoeff <- path_coeff(data_ge2, resp = KW)
>> Error in matrix(value, n, p) :
>>   data length differs from size of matrix: [196 != 1 x 14]
>> Calls: path_coeff -> [<- -> [<-.data.frame -> matrix
>> Execution halted
>>
>> In the current R-devel the matrix command matrix(value, nrow, ncol) complains if length(value)>nrow*ncol, so you need to truncate 'value'.  (Previously matrix() would silently truncate value.)
>>
>>
>> -Bill
>>
>>
>> On Thu, Jun 3, 2021 at 5:57 PM Tiago Olivoto <tiagoolivoto using gmail.com>
>> wrote:
>>
>>> Dear all,
>>> I have received an email from the CRAN team to fix a problem with my R
>>> package metan <https://CRAN.R-project.org/package=metan
>>> <https://cran.r-project.org/package=metan>> to safely retain it on CRAN.
>>>
>>> The error is given at <
>>> https://www.stats.ox.ac.uk/pub/bdr/donttest/metan.out>
>>> and seems to be related to data different from size of matrix.
>>>
>>> The question is that and I cannot reproduce the error locally and thus
>>> not
>>> able to fix anything. By googling the error I've seen similar issues
>>> with a
>>> lot of other packages. Could be this be a temporary issue?
>>>
>>> Thanks in advance!
>>> Tiago
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-package-devel using r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>>>
>>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list