楼主: lhemivw
2691 1

[问答] 请教下orthogonal signal correction(OSC),有没有包可以用呢? [推广有奖]

  • 0关注
  • 0粉丝

小学生

0%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
37 点
帖子
3
精华
0
在线时间
4 小时
注册时间
2010-9-21
最后登录
2014-5-6

楼主
lhemivw 发表于 2013-2-23 15:54:13 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
只看到有matlab的脚本,没见到R的,求助转成R的
function [x,nw,np,nt] = osccalc(x,y,nocomp,iter,tol)
%OSCCALC Calculates orthogonal signal correction
%  The inputs are the matrix of predictor variables (x)
%  and predicted variable(s) (y), scaled as desired, and
%  the number of OSC components to calculate (nocomp).
%  Optional input variables are the maximum number of
%  iterations used in attempting to maximize the variance
%  captured by orthogonal component (iter, default = 0),
%  and the tolerance on percent of x variance to consider
%  in formation of the final w vector (tol, default = 99.9).
%  The outputs are the OSC corrected x matrix (nx) and
%  the weights (nw), loads (np) and scores(nt) that were
%  used in making the correction. Once the calibration is
%  done, new (scaled) x data can be corrected by
%  newx = x - x*nw*inv(np'*nw)*np';
%
%I/O: [nx,nw,np,nt] = osccalc(x,y,nocomp,iter,tol);
%
%See also: CROSSVAL
%Copyright Eigenvector Research, Inc. 1998
%Barry M. Wise, January 23, 1998

[m,n] = size(x);

nw = zeros(n,nocomp);

np = zeros(n,nocomp);

nt = zeros(m,nocomp);

if nargin < 4 | isempty(iter)

iter = 0;

end

if nargin < 5 | isempty(tol)

  tol= 99.9;

end

for i = 1:nocomp

  %Calculate the first score vector

[u,s,v] = svds(x,1);

  p =v(:,1);

  p =p*sign(sum(p));

told = u(:,1)*s(1);

  dif= 1;

  k =0;

while dif > 1e-12

    k= k+1;

    %Calculate scores from loads

    t= x*p/(p'*p);

    %Othogonalize t to y

       tnew= t - y*inv(y'*y)*y'*t;

    %Compute a new loading

   pnew = x'*tnew/(tnew'*tnew);

    %Check for convergence

   dif = norm(tnew-told)/norm(tnew);

    %Assign pnew to p

   told = tnew;

    p= pnew;

   if k > iter

     dif = 0;

       end

  end

  %Build PLS model relating x to t

  nc= rank(x);

[w,ssq] = pls(x,tnew,nc,0);

  %Include components as specified by tol on x variance

  z =size(find(ssq(:,3)<tol));

  nc= z(1)+1;

  w =w(nc,:)';  

  w =w/norm(w);

  %Calculate new scores vector

  t =x*w;

  %Othogonalize t to y

  t =t - y*inv(y'*y)*y'*t;

  %Compute new p

  p =x'*t/(t'*t);

  %Remove orthogonal signal from x

  x =x - t*p';

np(:,i) = p;

nw(:,i) = w;

nt(:,i) = t;

end


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Orthogonal Correction correct Signal correc orthogonal function default

沙发
lhemivw 发表于 2013-2-26 16:57:05
看来这个很难啊,顶顶

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-6 02:01