In general, there is a positive correlation between faith and works, but the presence of works is neither direct nor circumstantial evidence of the presence of faith, nor is the absence of works evidence of the absence of faith. This was the point of the interlocutor in James 2:18-19, and James didn't rebut the point except to reiterate that faith apart from works is useless to other people (verses 14-16) and then proceeded to show that faith and works can complement each other and do wonderful things together (verses 20-25).
To show that faith and works cannot respectively serve as evidence for one another, it is sufficient to give a few examples from the New Testament. The people in Matthew 7:21-23 had plenty of good works, but the presence of those works was not evidence that they were justified by faith. Likewise, Judas had plenty of good works and had a deep relationship with Jesus for over three years, but he was not justified by faith. Jesus said in John 6:64 that he didn't believe. In contrast, a man in 1 Corinthians 5:1-13 had an absence of works and was actually living a life worse than a pagan, but the absence of works was not evidence that he was not justified by faith. This is why Paul could go no further than to refer to him as someone "called a brother" in verse 11. The man's works were absolutely contrary to what is expected of the Christian life, but Paul did not call him a "false brother" (in contrast to people who Paul called "false apostles" and "false brothers" in 2 Corinthians 11:13, 26 and Galatians 2:4 because of their profession of a false gospel). The man in 1 Corinthians 5 might have been a false brother if he didn't actually believe the Gospel, but because works are not evidence of faith, Paul did not call him a "false brother." Instead, Paul was actually confident that the chastisement of the Lord would save him (perhaps "preserve him whole") on the day of the Lord, indicating that he gave the man the benefit of the doubt. In addition, Paul does a similar thing in 2 Timothy 2:17-19 where he seems to question the faith of some people who held wrong views on the resurrection, but does not go so far as to say they were "false brothers" but commits the issue to God saying, "The Lord knows those who are His." Their works, and this case especially their doctrine, was wrong, but that could not be used as evidence of them being "false brothers." Only God knew if they had believed the Gospel and were justified by faith alone. However, just like in previous example, Paul here, too, expected that God would use chastisement to bring correction to believers (verses 25-26). In addition to these two examples where a lack of works was not evidence of lack of justifying faith, I could easily multiply examples, such as Acts 19:11-20, 1 Corinthians 11:17-34, and James 4:1-10, where people who were justified by faith were living lives very contrary to what we would expect of Christians. In each case, it is the chastisement of the Lord that corrects believers, and in some extreme cases like the Corinthians who presumably refused to repent, chastisement could result in premature death, although Paul assures us that this was not to be mistaken for condemnation. They died as justified people. In all cases given above, neither faith nor works can respectively serve as evidence for the other.
There is positive correlation between faith and works because works empower faith, just like a spirit empowers a body (James 2:26). The presence of a spirit is not evidence of a body, nor a body evidence of a spirit. However, when a spirit and a body come together, they can do great things. Likewise, when works come together with faith, there is synergy (the Greek verb James uses in verse 22 is synergeo, which means "work together") that enables them to do great things like they did for Abraham and Rahab. For other examples of this synergy, I suggest reading Hebrews 11, while noticing that faith is defined in verse 1 as assurance or conviction of the truth of something not seen. Faith is simply a persuasion of the mind. Nothing more. But when combined with works, there is no limit to the great things that can be done.