0

matbugs インターフェイスを使用しようとしていますが、いくつかの問題が発生しており、助けを求めていました。私は新しい matlab ユーザーであり、matlab が特定のファイルを「tmp」フォルダーに書き込まないという問題を修正するのに苦労しています。具体的には、コードは data.txt ファイルと init_1.txt (初期値のセットが 1 つしかない場合) を書き込みますが、他のファイルは書き込みません。ブレークポイントを設定してコードを実行すると、ファイル パスは作成されますが、実際のファイルは作成されません。プログラムが bugs2mat 関数に存在しない codaIndex.txt ファイルの「ファイル名」パスを読み込もうとすると、エラーが発生します。

ここにコードがあります

    clear all

    % Read in the data files
    [SubID, Y, RewLos, T, N] = ReadInData();

    % WinBUGS Parameters
    % Total number of samples per chain = nburnin + nsamples*thin
    nchains=3; % Number of MCMC chains
    nburnin=2000; % Number of burn-in samples
    nsamples=300; % Number of samples aften burn-in
    thin = 50; % How often a sample is recorded (thin = 1 means every sample is                 recorded)

    % Assign Matlab Variables to the Observed WinBUGS Nodes
    %Data provided to BUGS are: RewLos[1:2, 1:T, 1:N], Y[1:N, 1:T], N, & T[i]
    datastruct = struct('Y', Y, 'RewLos', RewLos,'T',T, 'N', N);

    %Initialize Unobserved Variables
    for i=1:nchains
        S.muA = .5;
        S.muW = .5;
        S.muC = .2;
        S.muG = .2;
        S.lambdaA = 1;
        S.lambdaW = 1;
        S.lambdaC = 1;
        S.lambdaG = 1;
        S.a = unifrnd(0.4,0.6,N,1);
        S.w = unifrnd(0.4,0.6,N,1);
        S.c = unifrnd(0.1,0.3,N,1);
        S.g = unifrnd(0.1,0.3,N,1);
        init0(i) = S;
    end

    % Use WinBUGS to Sample
    [samples, stats] = matbugs(datastruct, ...
        fullfile(pwd, 'PVL_truncNormal.txt'), ...
        'init', init0, ...
        'nChains', nchains, ...
        'view', 0, 'nburnin', nburnin, 'nsamples', nsamples, ...
        'thin', thin, 'DICstatus', 0, 'refreshrate',100, ...
        'monitorParams', {'a', 'w', 'c', 'g', 'muA', 'muW', 'muC', 'muG', 'sigmaA',                 'sigmaW', 'sigmaC', 'sigmaG'}, ... % Samples to track
        'Bugdir', 'E:/WinBUGS14');

    % Save output from bugs
    savefile = 'PVL_FLIGT_StatPG.mat';
    save(savefile, 'samples', 'stats')
4

0 に答える 0