From 73290f14d58e916897ea7464341b6ab553a9591a Mon Sep 17 00:00:00 2001 From: GregFa Date: Fri, 26 Apr 2024 21:44:49 -0500 Subject: [PATCH] removed old backtransform function --- src/utilities/std_helpers.jl | 119 ----------------------------------- 1 file changed, 119 deletions(-) diff --git a/src/utilities/std_helpers.jl b/src/utilities/std_helpers.jl index 6cf393d..8f03fb5 100644 --- a/src/utilities/std_helpers.jl +++ b/src/utilities/std_helpers.jl @@ -36,125 +36,6 @@ function normalize!(A::AbstractArray{Float64,2}, hasIntercept::Bool) return means, norms end - -""" - backtransform!(B::AbstractArray{Float64,2}, - meansX::AbstractArray{Float64,2}, - meansZ::AbstractArray{Float64,2}, - normsX::AbstractArray{Float64,2}, - normsZ::AbstractArray{Float64,2}, - Y::AbstractArray{Float64,2}, - Xold::AbstractArray{Float64,2}, - Zold::AbstractArray{Float64,2}) - -Back-transform coefficient estimates B in place if X and Z were standardized -prior to the estimation-- when both X and Z include intercept columns. - -# Arguments - -- B = 2d array of coefficient estimates B -- meansX = 2d array of column means of X, obtained prior to standardizing X -- meansZ = 2d array of column means of Z, obtained prior to standardizing Z -- normsX = 2d array of column norms of X, obtained prior to standardizing X -- normsZ = 2d array of column norms of Z, obtained prior to standardizing Z -- Y = 2d array of response matrix Y -- Xold = 2d array row covariates X prior to standardization -- Zold = 2d array column covariates Z prior to standardization - -# Value - -None; back-transforms B in place - -""" -function backtransform!(B::AbstractArray{Float64,2}, - meansX::AbstractArray{Float64,2}, - meansZ::AbstractArray{Float64,2}, - normsX::AbstractArray{Float64,2}, - normsZ::AbstractArray{Float64,2}, - Y::AbstractArray{Float64,2}, - Xold::AbstractArray{Float64,2}, - Zold::AbstractArray{Float64,2}) - - # Back transform the X intercepts (row main effects) - prodX = (meansX[:,2:end]./normsX[:,2:end])*B[2:end, 2:end] - B[1,2:end] = (B[1,2:end]-vec(prodX))./vec(normsZ[:,2:end])/normsX[1,1] - - # Back transform the Z intercepts (column main effects) - prodZ = B[2:end, 2:end]*transpose(meansZ[:,2:end]./normsZ[:,2:end]) - B[2:end,1] = (B[2:end,1]-prodZ)./transpose(normsX[:,2:end])/normsZ[1,1] - - # Back transform the interactions - B[2:end, 2:end] = B[2:end, 2:end]./transpose(normsX[:,2:end])./ - normsZ[:,2:end] - - # Re-estimate intercept - B[1,1] = 0 - B[1,1] = mean(Y-Xold*B*transpose(Zold)) -end - - -""" - backtransform!(B::AbstractArray{Float64,2}, - addXIntercept::Bool, addZIntercept::Bool, - meansX::AbstractArray{Float64,2}, - meansZ::AbstractArray{Float64,2}, - normsX::AbstractArray{Float64,2}, - normsZ::AbstractArray{Float64,2}) - -Back-transform coefficient estimates B in place if X and Z were standardized -prior to the estimation-- when not including intercept columns for either X -or Z. - -# Arguments - -- B = 2d array of coefficient estimates B -- addXIntercept = boolean flag indicating whether or not to X has an - intercept column -- addZIntercept = boolean flag indicating whether or not to Z has an - intercept column -- meansX = 2d array of column means of X, obtained prior to standardizing X -- meansZ = 2d array of column means of Z, obtained prior to standardizing Z -- normsX = 2d array of column norms of X, obtained prior to standardizing X -- normsZ = 2d array of column norms of Z, obtained prior to standardizing Z - -# Value - -None; back-transforms B in place - -""" -function backtransform!(B::AbstractArray{Float64,2}, - addXIntercept::Bool, addZIntercept::Bool, - meansX::AbstractArray{Float64,2}, - meansZ::AbstractArray{Float64,2}, - normsX::AbstractArray{Float64,2}, - normsZ::AbstractArray{Float64,2}) - - # Back transform the X intercepts (row main effects), if necessary - if addXIntercept == true - prodX = (meansX[:,2:end]./normsX[:,2:end])*B[2:end, 2:end] - B[1,2:end] = (B[1,2:end]-vec(prodX))./vec(normsZ[:,2:end])/normsX[1,1] - end - - # Back transform the Z intercepts (column main effects), if necessary - if addZIntercept == true - prodZ = B[2:end, 2:end]*transpose(meansZ[:,2:end]./normsZ[:,2:end]) - B[2:end,1] = (B[2:end,1]-prodZ)./transpose(normsX[:,2:end])/ - normsZ[1,1] - end - - # Back transform the interactions, if necessary - if (addXIntercept == true) || (addZIntercept == true) - B[2:end, 2:end] = B[2:end, 2:end]./transpose(normsX[:,2:end])./ - normsZ[:,2:end] - end - - # Back transform the interactions if not including any main effects - if (addXIntercept == false) && (addZIntercept == false) - B = B./transpose(normsX)./normsZ - end -end - - """ backtransform!(B::AbstractArray{Float64,4}, addXIntercept::Bool, addZIntercept::Bool,